home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / gnu / bash / bug / 503 < prev    next >
Encoding:
Text File  |  1992-07-27  |  2.0 KB  |  56 lines

  1. Newsgroups: gnu.bash.bug
  2. Path: sparky!uunet!cis.ohio-state.edu!odin.ins.cwru.edu!chet
  3. From: chet@odin.ins.cwru.edu (Chet Ramey)
  4. Subject: Re: problem with bash 1.12.1 w/ trap
  5. Message-ID: <9207271152.AA08259.SM@odin.INS.CWRU.Edu>
  6. Sender: gnulists@ai.mit.edu
  7. Reply-To: chet@po.cwru.edu
  8. Organization: GNUs Not Usenet
  9. References: chet@odin.ins.cwru.edu (Chet Ramey)
  10. Distribution: gnu
  11. Date: Mon, 27 Jul 1992 03:52:17 GMT
  12. Approved: bug-bash@prep.ai.mit.edu
  13. Lines: 41
  14.  
  15. > Currently, I cannot get scripts with trap in them to work correctly
  16. > under bash version 1.12.1.
  17.  
  18. I rewrote the trap and signal handling code for the next version, which
  19. should correct many of the bugs people have found.
  20.  
  21. >   delay=6
  22. >   trap 'trap 14' 14
  23. >   echo "What is your Quest? \c"
  24. >   (sleep $delay; kill -14 $$ 2>/dev/null)&
  25. >   read YourQuest
  26. >   kill $! 2>/dev/null
  27. >   [ ! -z "$YourQuest" ] && echo "Bah. Humbug. Not interested in $YourQuest" \
  28. >                         || echo "You must be interested in something!"
  29.  
  30. You're expecting the SIGALRM to interrupt the read, I'm sure.  It doesn't
  31. do so on BSD systems.  On my SunOS 4.1.2 systems, after changing the above
  32. trap command to `trap "echo 14 ; trap 14" 14', I found that out of bash,
  33. ksh-88, /bin/sh, ash, the new BSD sh, and zsh, only bash and zsh even
  34. printed the `14'.  None of those shells let the SIGALRM interrupt the
  35. `read'.
  36.  
  37. >   PATH=/bin:/usr/bin
  38. >   trap "" 1 2 3 4 5 6 7 8 '9' 10 11 12 13 14 15 16 17 18 \
  39. >                   19 20 21 22 23 24 25 26 27 28 29 30 31
  40. >   set - $(who am i)
  41. >   echo $1
  42.  
  43. The specific problem with this script is that you've told bash to ignore
  44. SIGCHLD, and version 1.12 does not handle that correctly.  (It sets the
  45. SIGCHLD handler to SIG_IGN in the child shell created to run the command
  46. substitution, and that shell never reaps the `who' and exits.)
  47.  
  48. Chet
  49.  
  50. --
  51. ``The use of history as therapy means the corruption of history as history.''
  52.     -- Arthur Schlesinger
  53.  
  54. Chet Ramey, Case Western Reserve University    Internet: chet@po.CWRU.Edu
  55.  
  56.