ольга крыжановская
2013-07-11 06:11:04 UTC
Why does ksh93 use SIGALRM internally to implement sleep? It looks a
bit byzantine, aside from the issue that the code in
src/cmd/ksh93/sh/fault.c can never work, as intended:
if(shp->savesig)
{
/* critical region, save and process later */
if(!(shp->sigflag[sig]&SH_SIGIGNORE))
shp->savesig = sig;
return;
}
if(sig==SIGALRM && shp->bltinfun==b_sleep)
{
if(trap && *trap)
{
shp->trapnote |= SH_SIGTRAP;
shp->sigflag[sig] |= SH_SIGTRAP;
#ifdef _lib_sigaction
set_trapinfo(shp,sig,info);
#endif
}
return;
}
I can imagine so many problems caused by this.
1. if(shp->savesig)/return; - if this code is *ever* executed for a
signal we loose the siginfo data for this signal.
2. if(sig==SIGALRM && shp->bltinfun==b_sleep) happens only during
builtin sleep(1), but at the same time it cannot work because this is
an asynchronous timer signal which can happen at *any* time, while
being inside b_sleep(), or not. There is no guarantee by POSIX that it
should arrive exactly then.
IMO the whole byzantine SIGALRM code should be removed.
Olga
bit byzantine, aside from the issue that the code in
src/cmd/ksh93/sh/fault.c can never work, as intended:
if(shp->savesig)
{
/* critical region, save and process later */
if(!(shp->sigflag[sig]&SH_SIGIGNORE))
shp->savesig = sig;
return;
}
if(sig==SIGALRM && shp->bltinfun==b_sleep)
{
if(trap && *trap)
{
shp->trapnote |= SH_SIGTRAP;
shp->sigflag[sig] |= SH_SIGTRAP;
#ifdef _lib_sigaction
set_trapinfo(shp,sig,info);
#endif
}
return;
}
I can imagine so many problems caused by this.
1. if(shp->savesig)/return; - if this code is *ever* executed for a
signal we loose the siginfo data for this signal.
2. if(sig==SIGALRM && shp->bltinfun==b_sleep) happens only during
builtin sleep(1), but at the same time it cannot work because this is
an asynchronous timer signal which can happen at *any* time, while
being inside b_sleep(), or not. There is no guarantee by POSIX that it
should arrive exactly then.
IMO the whole byzantine SIGALRM code should be removed.
Olga
--
, _ _ ,
{ \/`o;====- Olga Kryzhanovska -====;o`\/ }
.----'-/`-/ olga.kryzhanovska at gmail.com \-`\-'----.
`'-..-| / http://twitter.com/fleyta \ |-..-'`
/\/\ Solaris/BSD//C/C++ programmer /\/\
`--` `--`
, _ _ ,
{ \/`o;====- Olga Kryzhanovska -====;o`\/ }
.----'-/`-/ olga.kryzhanovska at gmail.com \-`\-'----.
`'-..-| / http://twitter.com/fleyta \ |-..-'`
/\/\ Solaris/BSD//C/C++ programmer /\/\
`--` `--`