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 [EMAIL PROTECTED]<mailto:mkneme=
> [EMAIL PROTECTED]>. My email address is [EMAIL PROTECTED]<mailto:[EMAIL
> PROTECTED]
> lsi.com>. I believe [EMAIL PROTECTED]<mailto:[EMAIL PROTECTED]> is the=
> email address in ast-users.
> Could someone kindly reply that you have seen this posting.
> Thanks,
> Mike Nemeth
> Global Engineering Systems
> [EMAIL PROTECTED]
> * Office 610 712 8106
> * Cell 610 653 8847
> ________________________________
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> .att.com] On Behalf Of Nemeth, Michael Kenneth (Mike)
> Sent: Monday, October 06, 2008 10:05 AM
> To: [email protected]
> 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] =3D '\0';
> fgets(s,1023,stdin);
> printf("Read %s\n",s);
> if ((errno !=3D EINTR) && (s[0] =3D=3D '\0')){ printf("parent died=
> \n");exit(1); }
> if (strstr(s,"stop") !=3D 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=3DContent-Type content=3D"text/html; charset=3Dus-ascii">
> <META content=3D"MSHTML 6.00.2900.3395" name=3DGENERATOR><!-- converted fro=
> m rtf -->
> <STYLE>.EmailQuote {
> PADDING-LEFT: 4pt; MARGIN-LEFT: 1pt; BORDER-LEFT: #800000 2px solid
> }
> </STYLE>
> </HEAD>
> <BODY>
> <DIV dir=3Dltr align=3Dleft><FONT face=3DArial color=3D#0000ff size=3D2><SP=
> AN=20
> class=3D938334519-13102008>Hi,</SPAN></FONT></DIV>
> <DIV dir=3Dltr align=3Dleft><FONT face=3DArial color=3D#0000ff size=3D2><SP=
> AN=20
> class=3D938334519-13102008></SPAN></FONT> </DIV>
> <DIV dir=3Dltr align=3Dleft><FONT face=3DArial color=3D#0000ff size=3D2><SP=
> AN=20
> class=3D938334519-13102008>Recently my company has removed contact to <A=20
> href=3D"mailto:[EMAIL PROTECTED]">[EMAIL PROTECTED]</A>. My email a=
> ddress=20
> is <A href=3D"mailto:[EMAIL PROTECTED]">[EMAIL PROTECTED]</A>. I =
> believe=20
> <A href=3D"mailto:[EMAIL PROTECTED]">[EMAIL PROTECTED]</A> is the email=
> =20
> address in ast-users.</SPAN></FONT></DIV>
> <DIV dir=3Dltr align=3Dleft><FONT face=3DArial color=3D#0000ff size=3D2><SP=
> AN=20
> class=3D938334519-13102008></SPAN></FONT> </DIV>
> <DIV dir=3Dltr align=3Dleft><FONT face=3DArial color=3D#0000ff size=3D2><SP=
> AN=20
> class=3D938334519-13102008>Could someone kindly reply that you have seen th=
> is=20
> posting.</SPAN></FONT></DIV>
> <DIV dir=3Dltr align=3Dleft><FONT face=3DArial color=3D#0000ff size=3D2><SP=
> AN=20
> class=3D938334519-13102008></SPAN></FONT> </DIV>
> <DIV dir=3Dltr align=3Dleft><FONT face=3DArial color=3D#0000ff size=3D2><SP=
> AN=20
> class=3D938334519-13102008>Thanks,</SPAN></FONT></DIV><!-- Converted from t=
> ext/rtf format -->
> <P align=3Dleft><SPAN lang=3Den-us><B><FONT face=3D"Comic Sans MS" color=3D=
> #999999=20
> size=3D2>Mike Nemeth</FONT></B></SPAN><SPAN lang=3Den-us><BR></SPAN><SPAN=20
> lang=3Den-us><FONT face=3DArial color=3D#999999 size=3D2>Global Engineering=
> =20
> Systems</FONT></SPAN><SPAN lang=3Den-us><BR></SPAN><SPAN lang=3Den-us></SPA=
> N><SPAN=20
> lang=3Den-us></SPAN><SPAN lang=3Den-us><BR></SPAN><SPAN lang=3Den-us><B><FO=
> NT=20
> face=3DWingdings color=3D#808080>+</FONT></B></SPAN><SPAN lang=3Den-us><B><=
> FONT=20
> color=3D#999999>[EMAIL PROTECTED]</FONT></B></SPAN><SPAN=20
> lang=3Den-us><BR><B></B></SPAN><SPAN lang=3Den-us><B><FONT face=3DWingdings=
> =20
> color=3D#808080 size=3D2>(</FONT></B></SPAN><SPAN lang=3Den-us></SPAN><SPAN=
> =20
> lang=3Den-us><FONT face=3DArial size=3D2> </FONT></SPAN><SPAN=20
> lang=3Den-us><B></B></SPAN><SPAN lang=3Den-us><B><FONT face=3DArial color=
> =3D#999999=20
> size=3D2>Office</FONT></B></SPAN><SPAN lang=3Den-us></SPAN><SPAN lang=3Den-=
> us><FONT=20
> face=3DArial size=3D2> </FONT></SPAN><SPAN lang=3Den-us></SPAN><SPAN l=
> ang=3Den-us>=20
> <FONT face=3DArial color=3D#999999 size=3D2>610 712 8106</FONT></SPAN><SPAN=
> =20
> lang=3Den-us></SPAN><SPAN lang=3Den-us><BR></SPAN><SPAN=20
> lang=3Den-us><B></B></SPAN><SPAN lang=3Den-us><B><FONT face=3DWingdings col=
> or=3D#808080=20
> size=3D2>(</FONT></B></SPAN><SPAN lang=3Den-us></SPAN><SPAN lang=3Den-us><F=
> ONT=20
> face=3DArial size=3D2> </FONT></SPAN><SPAN lang=3Den-us><B></B></SPAN>=
> <SPAN=20
> lang=3Den-us><B><FONT face=3DArial color=3D#999999 size=3D2>Cell</FONT></B>=
> </SPAN><SPAN=20
> lang=3Den-us></SPAN><SPAN lang=3Den-us><FONT face=3DArial color=3D#999999=20
> size=3D2></FONT></SPAN><SPAN lang=3Den-us></SPAN><SPAN lang=3Den-us> <FONT =
> face=3DArial=20
> size=3D2> </FONT></SPAN><SPAN lang=3Den-us></SPAN><S=
> PAN=20
> lang=3Den-us> <FONT face=3DArial color=3D#999999 size=3D2>610 653=20
> 8847</FONT></SPAN><SPAN lang=3Den-us></SPAN><SPAN lang=3Den-us></SPAN></P>
> <DIV> </DIV><BR>
> <DIV class=3DOutlookMessageHeader lang=3Den-us dir=3Dltr align=3Dleft>
> <HR tabIndex=3D-1>
> <FONT face=3DTahoma size=3D2><B>From:</B> [EMAIL PROTECTED]
> m=20
> [mailto:[EMAIL PROTECTED] <B>On Behalf Of </B>Nemeth, Mic=
> hael=20
> Kenneth (Mike)<BR><B>Sent:</B> Monday, October 06, 2008 10:05 AM<BR><B>To:<=
> /B>=20
> [email protected]<BR><B>Subject:</B> [ast-users] Ksh93 s+: SIGINT=
> =20
> handling when trap EXIT<BR></FONT><BR></DIV>
> <DIV></DIV><FONT face=3D"Arial, sans-serif" size=3D2>
> <DIV>Hi,</DIV>
> <DIV> </DIV>
> <DIV>I'm seeing different behavior in parent process SIGINT handling when p=
> arent=20
> has a trap set for EXIT and run from current shell vs. sub shell. Hop=
> ing=20
> that someone can comment if this is the correct behavior for ksh93 or a sof=
> tware=20
> bug. If a software bug what is the correct workaround. Would it be to=
> set=20
> a trap on SIGINT in the parent to ignore (i.e. trap '' SIGINT). =
> =20
> Details on my issue follow:</DIV>
> <DIV> </DIV>
> <DIV><U>Sample Test Program</U></DIV>
> <DIV> </DIV>
> <DIV style=3D"PADDING-LEFT: 19pt">/* Program compiled</DIV>
> <DIV style=3D"PADDING-LEFT: 19pt"> Linux pacelab2 2.6.9-67.ELsm=
> p #1=20
> SMP Wed Nov 7 13:56:44 EST 2007 x86_64 x86_64 x86_64 GNU/Linux</DIV>
> <DIV style=3D"PADDING-LEFT: 19pt"> command=20
> line gcc sysInt.c -o sysInt</DIV>
> <DIV style=3D"PADDING-LEFT: 19pt">*/</DIV>
> <DIV style=3D"PADDING-LEFT: 19pt">#include <signal.h></DIV>
> <DIV style=3D"PADDING-LEFT: 19pt">#include <errno.h></DIV>
> <DIV style=3D"PADDING-LEFT: 19pt"> </DIV>
> <DIV style=3D"PADDING-LEFT: 19pt">void myfunc(int sig)</DIV>
> <DIV style=3D"PADDING-LEFT: 19pt">{</DIV>
> <DIV style=3D"PADDING-LEFT: 19pt"> printf("Received=20
> %d\n",sig);</DIV>
> <DIV style=3D"PADDING-LEFT: 19pt">}</DIV>
> <DIV style=3D"PADDING-LEFT: 19pt"> </DIV>
> <DIV style=3D"PADDING-LEFT: 19pt">main ()</DIV>
> <DIV style=3D"PADDING-LEFT: 19pt">{</DIV>
> <DIV style=3D"PADDING-LEFT: 19pt"> char s[1024];</DIV>
> <DIV style=3D"PADDING-LEFT: 19pt"> sigset(SIGINT,myfunc);=
> </DIV>
> <DIV style=3D"PADDING-LEFT: 19pt"> sigset(SIGQUIT,myfunc)=
> ;</DIV>
> <DIV style=3D"PADDING-LEFT: 19pt"> printf("Started=20
> sysInt\n");</DIV>
> <DIV style=3D"PADDING-LEFT: 19pt"> while(1)</DIV>
> <DIV style=3D"PADDING-LEFT: 19pt"> {</DIV>
> <DIV style=3D"PADDING-LEFT: 19pt">  =
> ; s[0]=20
> =3D '\0';</DIV>
> <DIV style=3D"PADDING-LEFT: 19pt">  =
> ;=20
> fgets(s,1023,stdin);</DIV>
> <DIV style=3D"PADDING-LEFT: 19pt">  =
> ;=20
> printf("Read %s\n",s);</DIV>
> <DIV style=3D"PADDING-LEFT: 19pt">  =
> ; if=20
> ((errno !=3D EINTR) && (s[0] =3D=3D '\0')){ printf("parent=20
> died\n");exit(1); }</DIV>
> <DIV style=3D"PADDING-LEFT: 19pt">  =
> ; if=20
> (strstr(s,"stop") !=3D 0) exit(0);</DIV>
> <DIV style=3D"PADDING-LEFT: 19pt"> }</DIV>
> <DIV style=3D"PADDING-LEFT: 19pt">}</DIV>
> <DIV> </DIV>
> <DIV> </DIV>
> <DIV>1. When the sysInt program is run in current shell and not from subshe=
> ll=20
> script it works fine.</DIV>
> <DIV> </DIV>
> <DIV style=3D"PADDING-LEFT: 19pt">$ echo ${.sh.version}</DIV>
> <DIV style=3D"PADDING-LEFT: 19pt">Version M 1993-12-28 s+</DIV>
> <DIV style=3D"PADDING-LEFT: 19pt"> </DIV>
> <DIV style=3D"PADDING-LEFT: 19pt">$ trap 'echo exit' EXIT</DIV>
> <DIV style=3D"PADDING-LEFT: 19pt">$ ./sysInt</DIV>
> <DIV style=3D"PADDING-LEFT: 19pt">Started sysInt</DIV>
> <DIV style=3D"PADDING-LEFT: 19pt">I hit ^C</DIV>
> <DIV style=3D"PADDING-LEFT: 19pt">Received 2</DIV>
> <DIV style=3D"PADDING-LEFT: 19pt">Read </DIV>
> <DIV style=3D"PADDING-LEFT: 19pt">I hit ^C</DIV>
> <DIV style=3D"PADDING-LEFT: 19pt">Received 2</DIV>
> <DIV style=3D"PADDING-LEFT: 19pt">Read </DIV>
> <DIV style=3D"PADDING-LEFT: 19pt">I hit ^C</DIV>
> <DIV style=3D"PADDING-LEFT: 19pt">Received 2</DIV>
> <DIV style=3D"PADDING-LEFT: 19pt">Read</DIV>
> <DIV style=3D"PADDING-LEFT: 19pt">I type stop</DIV>
> <DIV style=3D"PADDING-LEFT: 19pt">Read stop</DIV>
> <DIV style=3D"PADDING-LEFT: 19pt"> </DIV>
> <DIV style=3D"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=3D"PADDING-LEFT: 19pt">$ echo ${.sh.version}</DIV>
> <DIV style=3D"PADDING-LEFT: 19pt">Version M 1993-12-28 s+</DIV>
> <DIV style=3D"PADDING-LEFT: 19pt"> </DIV>
> <DIV style=3D"PADDING-LEFT: 19pt">$ cat sysInt.sh</DIV>
> <DIV style=3D"PADDING-LEFT: 19pt">trap 'echo exit' EXIT</DIV>
> <DIV style=3D"PADDING-LEFT: 19pt">./sysInt</DIV>
> <DIV style=3D"PADDING-LEFT: 19pt"> </DIV>
> <DIV style=3D"PADDING-LEFT: 19pt">$ sysInt.sh</DIV>
> <DIV style=3D"PADDING-LEFT: 19pt">Started sysInt</DIV>
> <DIV style=3D"PADDING-LEFT: 19pt">I hit ^C</DIV>
> <DIV style=3D"PADDING-LEFT: 19pt">exit</DIV>
> <DIV style=3D"PADDING-LEFT: 19pt">Received 2</DIV>
> <DIV style=3D"PADDING-LEFT: 19pt">Read </DIV>
> <DIV style=3D"PADDING-LEFT: 19pt">$ Read </DIV>
> <DIV style=3D"PADDING-LEFT: 19pt">Read </DIV>
> <DIV style=3D"PADDING-LEFT: 19pt">parent died</DIV>
> <DIV style=3D"PADDING-LEFT: 19pt"> </DIV></FONT></BODY></HTML>
> --_000_572F0C094F37344EB2B046EF5508059D06FB3C37PALMAIL01lsicom_--
> --===============1298656494==
> Content-Type: text/plain; charset="us-ascii"
> MIME-Version: 1.0
> Content-Transfer-Encoding: 7bit
> Content-Disposition: inline
> _______________________________________________
> ast-users mailing list
> [email protected]
> https://mailman.research.att.com/mailman/listinfo/ast-users
> --===============1298656494==--
_______________________________________________
ast-users mailing list
[email protected]
https://mailman.research.att.com/mailman/listinfo/ast-users