incubator-stdcxx-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Martin Sebor (JIRA)" <j...@apache.org>
Subject [jira] Commented: (STDCXX-419) [AIX] shell daemon trap handler not evaluated for SIGHUP
Date Fri, 18 May 2007 23:29:16 GMT

    [ https://issues.apache.org/jira/browse/STDCXX-419?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12497085
] 

Martin Sebor commented on STDCXX-419:
-------------------------------------

Even though the problem seems to be real the test case above doesn't reproduce it. See the
details below:

-------- Original Message --------
Subject: Re: HPUX-DEVTOOLS: SIGHUP handler not executed
Date: Fri, 18 May 2007 15:57:04 -0600
From: Martin Sebor <sebor@roguewave.com>
Organization: Rogue Wave Software
To: Parker James <James.Parker@comverse.com>
CC: <hpux-devtools@cxx.cup.hp.com>
References: <50E39E40A21E60438C1DBE1D770E8D590C04FA@us-dnv-mail01.comverse.com>

Parker James wrote:
> Martin,
> 
> From what I see, it looks as if you compile t.c but never run it (so of
> course t.out doesn't exist).  Are you sure you're running the test such
> that a.out created from t.c is executed on all platforms you're testing?

That would be a problem, wouldn't it? Thanks for pointing out
yet another problem in my testing, James!

Fortunately, despite the typo the test case does behave as I
described on Tru64 (regardless of the shell). So I didn't make
as big a fool of myself as I thought I did and the question
still stands.

$ uname -sr; rm -f t.out; cc ~/tmp/t.c && ./a.out && cat t.out
OSF1 V5.1
cat: cannot open t.out

$ uname -sr; rm -f t.out; cc ~/tmp/t.c && ./a.out && cat t.out
HP-UX B.11.23
./t.sh[3]: 4443 Hangup
in handler...

Unfortunately (for me) though, the small test case works on AIX
just as it does on HP-UX. The reason I'm not happy about it is
because the real program that I reduced the test case from
doesn't. It has the same problem as on Tru64, albeit with one
important difference that I've just discovered: the shell on
AIX does matter. Both Bash and ksh behave as I expect while
/bin/sh exhibits the problem.

Martin

> 
> Jim Parker
> 
> -----Original Message-----
> From: owner-hpux-devtools@cxx.cup.hp.com
> [mailto:owner-hpux-devtools@cxx.cup.hp.com] On Behalf Of Martin Sebor
> Sent: Friday, May 18, 2007 4:39 PM
> To: hpux-devtools@cxx.cup.hp.com
> Subject: Re: HPUX-DEVTOOLS: SIGHUP handler not executed
> 
> Actually, I would still like to ask the same question if I may.
> I've reduced the behavior to a small test case that passes on HP-UX
> (among others) but fails on AIX *and* on HP Tru64 UNIX, so perhaps the
> issue is relevant to this forum after all.
> 
> The test case is on the following page:
>    https://issues.apache.org/jira/browse/STDCXX-419
> 
> and below for completeness. The behavior I expect when invoked like so:
> 'rm -f t.out; xlc ~/tmp/t.c && cat t.out' is for the last command to
> print the contents of the t.out file, i.e., "in handler..." This is the
> behavior I see HP-UX (and other
> systems) but not on Tru64 where the shell fails to create the t.out
> file.
> 
> So my revised question is: Am I relying on some sort of undefined or
> unspecified behavior or is there a bug on Tru64? (The shell appears to
> make no difference in the test case, the behavior is the same for Bash).
> 
> Thanks
> Martin
> 
> #include <signal.h>
> #include <stdio.h>
> #include <sys/stat.h>
> #include <sys/types.h>
> #include <unistd.h>
> 
> const char script[] = {
>     "#!/bin/sh\n"
>     "trap \"echo in handler... >t.out\" HUP EXIT\n"
>     "sleep 1000\n"
> };
> 
> int main ()
> {
>      FILE *fp;
>      pid_t pid;
> 
>      if (0 == (fp = fopen ("t.sh", "w"))) return 1;
>      fputs (script, fp);
> 
>      fclose (fp);
>      chmod ("t.sh", S_IRWXU);
> 
>      if (0 > (pid = fork ()))
>          return 2;
> 
>      if (0 < pid) {
>          sleep (1);
>          kill (-pid, SIGHUP);
>          return 0;
>      }
> 
>      if (-1 == setsid ()) return 3;
> 
>      execl ("./t.sh", (char*)0);
>      return 4;
> }
> 
> Martin Sebor wrote:
>> It's been suggested to me that I give specific details about the shell
> 
>> I'm using (thanks, Jim!) If I had thought to do so to begin with I 
>> might have realized I was using AIX and not HP-UX and sent my question
> 
>> to the right list ;-)
>>
>> HP-UX does evaluate the installed handler as expected.
>>
>> Sorry for the noise.
>>
>> Martin
>>
>> Martin Sebor wrote:
>>> I'm wondering if someone could help me understand why a SIGHUP 
>>> handler installed in a shell script would not be evaluated upon the 
>>> delivery of the signal when the script is invoked without a 
>>> controlling terminal (as a session leader created by calling 
>>> setsid()).
>>>
>>> The shell script installs the same handler for the following
>>> conditions: HUP INT QUIT TERM EXIT. When the process receives the 
>>> signal (sent to the whole group that the process is the session 
>>> leader of) it ends immediately and without invoking the handler. When
> 
>>> the script is changed to ignore SIGHUP instead the installed handler 
>>> is evaluated twice when SIGHUP (perhaps followed by SIGINT, I'm not 
>>> sure) is delivered.
>>>
>>> Thanks
>>> Martin
>>>
>>>  _________________________________________________________________
>>>  To leave this mailing list, send mail to majordomo@cxx.cup.hp.com
>>>     with the message UNSUBSCRIBE hpux-devtools  
>>> _________________________________________________________________


> [AIX] shell daemon trap handler not evaluated for SIGHUP
> --------------------------------------------------------
>
>                 Key: STDCXX-419
>                 URL: https://issues.apache.org/jira/browse/STDCXX-419
>             Project: C++ Standard Library
>          Issue Type: Bug
>          Components: External
>    Affects Versions: 4.1.2
>         Environment: AIX 5.2, 5.3
>            Reporter: Martin Sebor
>
> PMR 02346,K78,000
> The test case below is expected to run to completion and write to stdout the contents
of the file t.out (i.e., "in handler..."). It behaves as expected on HP-UX, Linux, and Solaris
but on AIX it fails to create the t.out file, indicating that the shell signal handler is
not evaluated.
> Since the behavior is the same regardless of the shell I suspect it's a bug in the OS.
> $ cat ~/tmp/t.c; rm -f t.out; xlc ~/tmp/t.c && cat t.out
> #include <signal.h>
> #include <stdio.h>
> #include <sys/stat.h>
> #include <sys/types.h>
> #include <unistd.h>
> const char script[] = {
>    "#!/bin/sh\n"
>    "trap \"echo in handler... >t.out\" HUP EXIT\n"
>    "sleep 1000\n"
> };
> int main ()
> {
>     FILE *fp;
>     pid_t pid;
>     if (0 == (fp = fopen ("t.sh", "w"))) return 1;
>     fputs (script, fp);
>     fclose (fp);
>     chmod ("t.sh", S_IRWXU);
>     if (0 > (pid = fork ()))
>         return 2;
>     if (0 < pid) {
>         sleep (1);
>         kill (-pid, SIGHUP);
>         return 0;
>     }
>     if (-1 == setsid ()) return 3;
>     execl ("./t.sh", (char*)0);
>     return 4;
> }
> cat: 0652-050 Cannot open t.out.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message