[prev in list] [next in list] [prev in thread] [next in thread]
List: ast-users
Subject: Re: [ast-users] RE: Ksh93 s+: SIGINT handling when trap EXIT
From: Glenn Fowler <gsf () research ! att ! com>
Date: 2008-10-14 22:17:56
Message-ID: 200810142217.m9EMHuO3019644 () penguin ! research ! att ! com
[Download RAW message or body]
this works on linux from the command line and a script for the latest ksh93t
Version M 93t 2008-10-14
and also for the final ksh93s+
Version M 93s+ 2008-05-07
On Mon, 13 Oct 2008 15:48:29 -0400 Nemeth, Michael Kenneth (Mike) wrote:
> Recently my company has removed contact to mknemeth@agere.com<mailto:mkneme> \
> th@agere.com>. My email address is mike.nemeth@lsi.com<mailto:mike.nemeth@> \
> lsi.com>. I believe mike.nemeth@lsi.com<mailto:mike.nemeth@lsi.com> is the> email \
> address in ast-users.
> Could someone kindly reply that you have seen this posting.
> Thanks,
> Mike Nemeth
> Global Engineering Systems
> *mike.nemeth@lsi.com
> * Office 610 712 8106
> * Cell 610 653 8847
> ________________________________
> From: ast-users-bounces@research.att.com [mailto:ast-users-bounces@research> \
> .att.com] On Behalf Of Nemeth, Michael Kenneth (Mike)
> Sent: Monday, October 06, 2008 10:05 AM
> To: ast-users@research.att.com
> Subject: [ast-users] Ksh93 s+: SIGINT handling when trap EXIT
> Hi,
> I'm seeing different behavior in parent process SIGINT handling when parent> has a \
> trap set for EXIT and run from current shell vs. sub shell. Hoping > that someone \
> can comment if this is the correct behavior for ksh93 or a sof> tware bug. If a \
> software bug what is the correct workaround. Would it be t> o set a trap on SIGINT \
> in the parent to ignore (i.e. trap '' SIGINT). Det> ails on my issue follow:
> Sample Test Program
> /* Program compiled
> Linux pacelab2 2.6.9-67.ELsmp #1 SMP Wed Nov 7 13:56:44 EST 2007 x86_64 > x86_64 \
> x86_64 GNU/Linux command line gcc sysInt.c -o sysInt
> */
> #include <signal.h>
> #include <errno.h>
> void myfunc(int sig)
> {
> printf("Received %d\n",sig);
> }
> main ()
> {
> char s[1024];
> sigset(SIGINT,myfunc);
> sigset(SIGQUIT,myfunc);
> printf("Started sysInt\n");
> while(1)
> {
> s[0] = '\0';
> fgets(s,1023,stdin);
> printf("Read %s\n",s);
> if ((errno != EINTR) && (s[0] == '\0')){ printf("parent died> \n");exit(1); }
> if (strstr(s,"stop") != 0) exit(0);
> }
> }
> 1. When the sysInt program is run in current shell and not from subshell sc> ript \
> it works fine.
> $ echo ${.sh.version}
> Version M 1993-12-28 s+
> $ trap 'echo exit' EXIT
> $ ./sysInt
> Started sysInt
> I hit ^C
> Received 2
> Read
> I hit ^C
> Received 2
> Read
> I hit ^C
> Received 2
> Read
> I type stop
> Read stop
> $
> 2. When program is run from a subshell script it doesn't work.
> $ echo ${.sh.version}
> Version M 1993-12-28 s+
> $ cat sysInt.sh
> trap 'echo exit' EXIT
> ./sysInt
> $ sysInt.sh
> Started sysInt
> I hit ^C
> exit
> Received 2
> Read
> $ Read
> Read
> parent died
> --_000_572F0C094F37344EB2B046EF5508059D06FB3C37PALMAIL01lsicom_
> Content-Type: text/html; charset="us-ascii"
> Content-Transfer-Encoding: quoted-printable
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
> <HTML><HEAD>
> <META http-equiv=Content-Type content="text/html; charset=us-ascii">
> <META content="MSHTML 6.00.2900.3395" name=GENERATOR><!-- converted fro> m rtf -->
> <STYLE>.EmailQuote {
> PADDING-LEFT: 4pt; MARGIN-LEFT: 1pt; BORDER-LEFT: #800000 2px solid
> }
> </STYLE>
> </HEAD>
> <BODY>
> <DIV dir=ltr align=left><FONT face=Arial color=#0000ff size=2><SP> AN
> class=938334519-13102008>Hi,</SPAN></FONT></DIV>
> <DIV dir=ltr align=left><FONT face=Arial color=#0000ff size=2><SP> AN
> class=938334519-13102008></SPAN></FONT> </DIV>
> <DIV dir=ltr align=left><FONT face=Arial color=#0000ff size=2><SP> AN
> class=938334519-13102008>Recently my company has removed contact to <A
> href="mailto:mknemeth@agere.com">mknemeth@agere.com</A>. My email a> ddress
> is <A href="mailto:mike.nemeth@lsi.com">mike.nemeth@lsi.com</A>. I > believe
> <A href="mailto:mike.nemeth@lsi.com">mike.nemeth@lsi.com</A> is the email>
> address in ast-users.</SPAN></FONT></DIV>
> <DIV dir=ltr align=left><FONT face=Arial color=#0000ff size=2><SP> AN
> class=938334519-13102008></SPAN></FONT> </DIV>
> <DIV dir=ltr align=left><FONT face=Arial color=#0000ff size=2><SP> AN
> class=938334519-13102008>Could someone kindly reply that you have seen th> is
> posting.</SPAN></FONT></DIV>
> <DIV dir=ltr align=left><FONT face=Arial color=#0000ff size=2><SP> AN
> class=938334519-13102008></SPAN></FONT> </DIV>
> <DIV dir=ltr align=left><FONT face=Arial color=#0000ff size=2><SP> AN
> class=938334519-13102008>Thanks,</SPAN></FONT></DIV><!-- Converted from t> ext/rtf \
> format --> <P align=left><SPAN lang=en-us><B><FONT face="Comic Sans MS" color=> \
> #999999 size=2>Mike Nemeth</FONT></B></SPAN><SPAN lang=en-us><BR></SPAN><SPAN
> lang=en-us><FONT face=Arial color=#999999 size=2>Global Engineering>
> Systems</FONT></SPAN><SPAN lang=en-us><BR></SPAN><SPAN lang=en-us></SPA> N><SPAN
> lang=en-us></SPAN><SPAN lang=en-us><BR></SPAN><SPAN lang=en-us><B><FO> NT
> face=Wingdings color=#808080>+</FONT></B></SPAN><SPAN lang=en-us><B><> FONT
> color=#999999>mike.nemeth@lsi.com</FONT></B></SPAN><SPAN
> lang=en-us><BR><B></B></SPAN><SPAN lang=en-us><B><FONT face=Wingdings>
> color=#808080 size=2>(</FONT></B></SPAN><SPAN lang=en-us></SPAN><SPAN>
> lang=en-us><FONT face=Arial size=2> </FONT></SPAN><SPAN
> lang=en-us><B></B></SPAN><SPAN lang=en-us><B><FONT face=Arial color> =#999999
> size=2>Office</FONT></B></SPAN><SPAN lang=en-us></SPAN><SPAN lang=en-> us><FONT
> face=Arial size=2> </FONT></SPAN><SPAN lang=en-us></SPAN><SPAN l> ang=en-us>
> <FONT face=Arial color=#999999 size=2>610 712 8106</FONT></SPAN><SPAN>
> lang=en-us></SPAN><SPAN lang=en-us><BR></SPAN><SPAN
> lang=en-us><B></B></SPAN><SPAN lang=en-us><B><FONT face=Wingdings col> or=#808080
> size=2>(</FONT></B></SPAN><SPAN lang=en-us></SPAN><SPAN lang=en-us><F> ONT
> face=Arial size=2> </FONT></SPAN><SPAN lang=en-us><B></B></SPAN>> <SPAN
> lang=en-us><B><FONT face=Arial color=#999999 size=2>Cell</FONT></B>> </SPAN><SPAN
> lang=en-us></SPAN><SPAN lang=en-us><FONT face=Arial color=#999999
> size=2></FONT></SPAN><SPAN lang=en-us></SPAN><SPAN lang=en-us> <FONT > face=Arial
> size=2> </FONT></SPAN><SPAN lang=en-us></SPAN><S> PAN
> lang=en-us> <FONT face=Arial color=#999999 size=2>610 653
> 8847</FONT></SPAN><SPAN lang=en-us></SPAN><SPAN lang=en-us></SPAN></P>
> <DIV> </DIV><BR>
> <DIV class=OutlookMessageHeader lang=en-us dir=ltr align=left>
> <HR tabIndex=-1>
> <FONT face=Tahoma size=2><B>From:</B> ast-users-bounces@research.att.co> m
> [mailto:ast-users-bounces@research.att.com] <B>On Behalf Of </B>Nemeth, Mic> hael
> Kenneth (Mike)<BR><B>Sent:</B> Monday, October 06, 2008 10:05 AM<BR><B>To:<> /B>
> ast-users@research.att.com<BR><B>Subject:</B> [ast-users] Ksh93 s+: SIGINT>
> handling when trap EXIT<BR></FONT><BR></DIV>
> <DIV></DIV><FONT face="Arial, sans-serif" size=2>
> <DIV>Hi,</DIV>
> <DIV> </DIV>
> <DIV>I'm seeing different behavior in parent process SIGINT handling when p> arent
> has a trap set for EXIT and run from current shell vs. sub shell. Hop> ing
> that someone can comment if this is the correct behavior for ksh93 or a sof> tware
> bug. If a software bug what is the correct workaround. Would it be to> set
> a trap on SIGINT in the parent to ignore (i.e. trap '' SIGINT). >
> Details on my issue follow:</DIV>
> <DIV> </DIV>
> <DIV><U>Sample Test Program</U></DIV>
> <DIV> </DIV>
> <DIV style="PADDING-LEFT: 19pt">/* Program compiled</DIV>
> <DIV style="PADDING-LEFT: 19pt"> Linux pacelab2 2.6.9-67.ELsm> p #1
> SMP Wed Nov 7 13:56:44 EST 2007 x86_64 x86_64 x86_64 GNU/Linux</DIV>
> <DIV style="PADDING-LEFT: 19pt"> command
> line gcc sysInt.c -o sysInt</DIV>
> <DIV style="PADDING-LEFT: 19pt">*/</DIV>
> <DIV style="PADDING-LEFT: 19pt">#include <signal.h></DIV>
> <DIV style="PADDING-LEFT: 19pt">#include <errno.h></DIV>
> <DIV style="PADDING-LEFT: 19pt"> </DIV>
> <DIV style="PADDING-LEFT: 19pt">void myfunc(int sig)</DIV>
> <DIV style="PADDING-LEFT: 19pt">{</DIV>
> <DIV style="PADDING-LEFT: 19pt"> printf("Received
> %d\n",sig);</DIV>
> <DIV style="PADDING-LEFT: 19pt">}</DIV>
> <DIV style="PADDING-LEFT: 19pt"> </DIV>
> <DIV style="PADDING-LEFT: 19pt">main ()</DIV>
> <DIV style="PADDING-LEFT: 19pt">{</DIV>
> <DIV style="PADDING-LEFT: 19pt"> char s[1024];</DIV>
> <DIV style="PADDING-LEFT: 19pt"> sigset(SIGINT,myfunc);> </DIV>
> <DIV style="PADDING-LEFT: 19pt"> sigset(SIGQUIT,myfunc)> ;</DIV>
> <DIV style="PADDING-LEFT: 19pt"> printf("Started
> sysInt\n");</DIV>
> <DIV style="PADDING-LEFT: 19pt"> while(1)</DIV>
> <DIV style="PADDING-LEFT: 19pt"> {</DIV>
> <DIV style="PADDING-LEFT: 19pt">  > ; s[0]
> = '\0';</DIV>
> <DIV style="PADDING-LEFT: 19pt">  > ;
> fgets(s,1023,stdin);</DIV>
> <DIV style="PADDING-LEFT: 19pt">  > ;
> printf("Read %s\n",s);</DIV>
> <DIV style="PADDING-LEFT: 19pt">  > ; if
> ((errno != EINTR) && (s[0] == '\0')){ printf("parent
> died\n");exit(1); }</DIV>
> <DIV style="PADDING-LEFT: 19pt">  > ; if
> (strstr(s,"stop") != 0) exit(0);</DIV>
> <DIV style="PADDING-LEFT: 19pt"> }</DIV>
> <DIV style="PADDING-LEFT: 19pt">}</DIV>
> <DIV> </DIV>
> <DIV> </DIV>
> <DIV>1. When the sysInt program is run in current shell and not from subshe> ll
> script it works fine.</DIV>
> <DIV> </DIV>
> <DIV style="PADDING-LEFT: 19pt">$ echo ${.sh.version}</DIV>
> <DIV style="PADDING-LEFT: 19pt">Version M 1993-12-28 s+</DIV>
> <DIV style="PADDING-LEFT: 19pt"> </DIV>
> <DIV style="PADDING-LEFT: 19pt">$ trap 'echo exit' EXIT</DIV>
> <DIV style="PADDING-LEFT: 19pt">$ ./sysInt</DIV>
> <DIV style="PADDING-LEFT: 19pt">Started sysInt</DIV>
> <DIV style="PADDING-LEFT: 19pt">I hit ^C</DIV>
> <DIV style="PADDING-LEFT: 19pt">Received 2</DIV>
> <DIV style="PADDING-LEFT: 19pt">Read </DIV>
> <DIV style="PADDING-LEFT: 19pt">I hit ^C</DIV>
> <DIV style="PADDING-LEFT: 19pt">Received 2</DIV>
> <DIV style="PADDING-LEFT: 19pt">Read </DIV>
> <DIV style="PADDING-LEFT: 19pt">I hit ^C</DIV>
> <DIV style="PADDING-LEFT: 19pt">Received 2</DIV>
> <DIV style="PADDING-LEFT: 19pt">Read</DIV>
> <DIV style="PADDING-LEFT: 19pt">I type stop</DIV>
> <DIV style="PADDING-LEFT: 19pt">Read stop</DIV>
> <DIV style="PADDING-LEFT: 19pt"> </DIV>
> <DIV style="PADDING-LEFT: 19pt">$</DIV>
> <DIV> </DIV>
> <DIV>2. When program is run from a subshell script it doesn't work.</DIV>
> <DIV> </DIV>
> <DIV style="PADDING-LEFT: 19pt">$ echo ${.sh.version}</DIV>
> <DIV style="PADDING-LEFT: 19pt">Version M 1993-12-28 s+</DIV>
> <DIV style="PADDING-LEFT: 19pt"> </DIV>
> <DIV style="PADDING-LEFT: 19pt">$ cat sysInt.sh</DIV>
> <DIV style="PADDING-LEFT: 19pt">trap 'echo exit' EXIT</DIV>
> <DIV style="PADDING-LEFT: 19pt">./sysInt</DIV>
> <DIV style="PADDING-LEFT: 19pt"> </DIV>
> <DIV style="PADDING-LEFT: 19pt">$ sysInt.sh</DIV>
> <DIV style="PADDING-LEFT: 19pt">Started sysInt</DIV>
> <DIV style="PADDING-LEFT: 19pt">I hit ^C</DIV>
> <DIV style="PADDING-LEFT: 19pt">exit</DIV>
> <DIV style="PADDING-LEFT: 19pt">Received 2</DIV>
> <DIV style="PADDING-LEFT: 19pt">Read </DIV>
> <DIV style="PADDING-LEFT: 19pt">$ Read </DIV>
> <DIV style="PADDING-LEFT: 19pt">Read </DIV>
> <DIV style="PADDING-LEFT: 19pt">parent died</DIV>
> <DIV style="PADDING-LEFT: 19pt"> </DIV></FONT></BODY></HTML>
> --_000_572F0C094F37344EB2B046EF5508059D06FB3C37PALMAIL01lsicom_--
> --==============98656494=> Content-Type: text/plain; charset="us-ascii"
> MIME-Version: 1.0
> Content-Transfer-Encoding: 7bit
> Content-Disposition: inline
> _______________________________________________
> ast-users mailing list
> ast-users@research.att.com
> https://mailman.research.att.com/mailman/listinfo/ast-users
> --==============98656494==--
_______________________________________________
ast-users mailing list
ast-users@research.att.com
https://mailman.research.att.com/mailman/listinfo/ast-users
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic