home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / unix / programm / 4003 < prev    next >
Encoding:
Text File  |  1992-07-29  |  1.8 KB  |  61 lines

  1. Xref: sparky comp.unix.programmer:4003 comp.unix.sysv386:12611
  2. Newsgroups: comp.unix.programmer,comp.unix.sysv386
  3. Path: sparky!uunet!usc!zaphod.mps.ohio-state.edu!magnus.acs.ohio-state.edu!usenet.ins.cwru.edu!wariat!erica
  4. From: erica@wariat.org (Lady of the BitMode)
  5. Subject: I/O of login shell
  6. Message-ID: <1992Jul29.220116.1634@wariat.org>
  7. Organization: Akademia Pana Kleksa, Public Access Uni* Site
  8. Distribution: usa
  9. Date: Wed, 29 Jul 1992 22:01:16 GMT
  10. Lines: 49
  11.  
  12. Hi.
  13.  
  14. I'm running SVR4. First a very very brief to help along the way.
  15. When a person logins into a unix system the system must first:
  16. 1) spawn a getty from teriminal
  17. 2)  getty runs login
  18. 3) then getty exec users specified shell, resorting to default, usually bourne,
  19. if none specified. 
  20. 4) user gets 3 basic file handles:
  21.    stdout 0, stdin 1, stderr 2.
  22.  
  23. Now, what I  want to do is run a background process that's basically 
  24. listens to file des #1 for a specified key sequence it will then 
  25. wakeup specific processes, that are sleeping in background, and 
  26. susend whatever the user is doing.
  27.  
  28. I know that the suspensions and wakeups are straight forward but the is
  29. there a nice way for a process to hang around in the background and
  30. listen to file descript. #1 for specific key sequence. I think that
  31. the following code might doit:
  32.  
  33. #include <stdio.h>
  34. void main( void ) ;
  35. void main( void )
  36.   {
  37.   int fd_in = 1 ;
  38.   for ( ;; ) 
  39.     {
  40.     TOP:
  41.     if ( (read( fd_in, &c, 1 )) && (c  == KEY1) ) 
  42.       {
  43.       /* do whatever */
  44.       }
  45.     }
  46.   }
  47.  
  48. Then run from command shell like :
  49. $ peekaboo & # run in background
  50.  
  51. Will this do the job or is there another function,  technique already
  52. proven, or is it just impossible. 
  53.  
  54. PS: I'm gonna go try the above. I know it's not going tobe a trivial task! :(
  55.  
  56. Thankyou:
  57.  
  58. Erica C. Ramsey
  59.  
  60. QuickBits & Turbo Nets Vroommmmmmmm!!!!
  61.