Hello,
while backporting a fix for the problem with wrong exit statuses we
have discovered a possible race condition in ksh-93 (reproduced in
version 2007-11-05) that causes ksh to "lose" an exit value.
The testing script is:
#!/bin/ksh
./test $1
ret=$?
echo $ret
exit $ret
where 'test' is a binary executable compiled from the following code:
#include <signal.h>
#include <stdlib.h>
#include <unistd.h>
static short unsigned int can_exit = 0;
void sighandler(int signum)
{
can_exit = 1;
}
int main (int argc, char ** argv)
{
int retval = 0;
if (argc > 0)
{
retval = atoi(argv[1]);
}
signal(SIGCONT, sighandler);
signal(SIGINT, sighandler);
while (!can_exit)
{
sleep(1);
}
return retval;
}
The test results look like this (stopping the running script with ^Z):
ksh$ ./stopandcont.ksh 13
[1] + Stopped ./stopandcont.ksh 13
ksh$ fg
./stopandcont.ksh 13
0
ksh$ ./stopandcont.ksh 13
[1] + Stopped ./stopandcont.ksh 13
ksh$ fg
./stopandcont.ksh 13
13
ksh$
As you can see the return value is sometimes 0. The test is the very
same as in
https://mailman.research.att.com/pipermail/ast-developers/2007q2/000172.html
and my guess is that the two issues are related. I'm trying to
investigate the problem, so if anyone finds a solution or has any
remarks, please let me know (even off-list).
Thanks and regards.
--
Tomáš Smetana
Base OS Software Engineer, Red Hat
RH IRC: #brno #devel #base-os; Freenode IRC: #fedora-devel
_______________________________________________
ast-developers mailing list
[email protected]
https://mailman.research.att.com/mailman/listinfo/ast-developers