Re: trap problem on bash 4.2
On 3/21/11 8:46 AM, sky wrote: > Bash Version: 4.2 > Patch Level: 8 > Release Status: release > > Description: > I am a programmer working in Japan. > I encountered an incompatibility between bash 4.2 and 4.1. Thanks for the report. I made some changes in this area between bash-4.1 and bash-4.2 in response to a Posix interpretation: http://austingroupbugs.net/view.php?id=53 I think Posix is ambiguous about the disposition of signals that are ignored when a new shell or subshell is started, or at least open to differing interpretations -- ksh93 behaves as bash-4.2 does, for instance, where dash and mksh behave like bash-4.1 -- but I think it's better not to deliberately introduce an incompatibility. I will revert to the bash-4.1 behavior for the next release. This may or may not come out as a patch to bash-4.2. Chet -- ``The lyf so short, the craft so long to lerne.'' - Chaucer ``Ars longa, vita brevis'' - Hippocrates Chet Ramey, ITS, CWRUc...@case.eduhttp://cnswww.cns.cwru.edu/~chet/
bizarre trap behavior while reading a file
I started execution of the following script and and repeatedly sent a SIGHUP to it from another shell. If SIGHUP is received within the first while loop the loop terminates with "wc -l" printing fewer than 4158 lines. If SIGHUP is received within the second while loop the loop still continues and the second "wc -l" prints always 4158 lines. I am really curious why is this happening!!! This is obviously a test scrip. I spent quite a long time debugging my work script to get to this point ;). #!/bin/bash log_file= line_num=0 trap "sig_received=true" HUP rm out.log cat $log_file | { while read line do line_num=`expr $line_num + 1` echo $line_num: $line >> ./out.log done } wc -l out.log rm out.log line_num=0 while read line do line_num=`expr $line_num + 1` echo $line_num: $line >> ./out.log done < $log_file wc -l out.log exit 0 -- View this message in context: http://old.nabble.com/bizarre-trap-behavior-while-reading-a-file-tp31242064p31242064.html Sent from the Gnu - Bash mailing list archive at Nabble.com.
Re: bizarre trap behavior while reading a file
On 3/25/11 5:25 PM, tytus64 wrote: > > I started execution of the following script and and repeatedly sent a SIGHUP > to it from another shell. If SIGHUP is received within the first while loop > the loop terminates with "wc -l" printing fewer than 4158 lines. If SIGHUP > is received within the second while loop the loop still continues and the > second "wc -l" prints always 4158 lines. > > I am really curious why is this happening!!! You don't say anything about what version of bash you're using or what OS you're on, but I couldn't reproduce it. I modified the script to print $$ at the beginning, so I knew which pid to hit, and hammered it with kill -HUP pid from another terminal. Each loop consumed and wrote 4158 lines. I tried it on both Mac OS X and RHEL 4 with the same results. Chet -- ``The lyf so short, the craft so long to lerne.'' - Chaucer ``Ars longa, vita brevis'' - Hippocrates Chet Ramey, ITS, CWRUc...@case.eduhttp://cnswww.cns.cwru.edu/~chet/