Mailing List Archive

Re: signal handling difference on HP vs. SUN
In <199511071826.TAA23035@broremann.hsr.no>
On Tue, 07 Nov 1995 19:29:44 +0100
Bjarne Steinsbo <bjarne@hsr.no> writes:
>> sub w{
>> $SIG{CHLD}=\&w;
>> $pid=wait;
>> print STDERR "died: $pid\n";
>> if ( $have == $pid ) { $have = 0; }
>> }
>>
>> Whether you reset it before/after the wait may be very important ...
>
>That's not the whole story... Another problem is that SIGCLD interrupts
>the read system call on SysV-ish (I like that word! :-) systems. This
>means that you have to test why "<STDIN>" fails, and act accodingly. A
>program that works on both Sun and HP is:

Tcl #defines read/write to its own versions which auto-retry?
Should perl do the same?
I guess move to SFIO will fix this too ;-)

>
>-------------
>$SIG{CHLD}=\&w;
>while(1){
> $_ = <STDIN>;
> $! = 0, next if $! =~ /Interrupted/;
> last if $! or !defined $_;
> if($have){
> print STDERR "child still alive\n";
> }
> else{
> if(($pid=fork()) != 0){
> $have=$pid;
> print STDERR "forked $pid\n";
> }
> else {
> exec("xterm -e vi")
> }
> }
>}
>