Comments (16)
So, the fix may be as simple as including AST <sig.h>
instead of <signal.h>
in that feature test, as the latter is included by the former and also includes the necessary extern for the rename mapping.
from ksh.
Works for me on macOS 12.7.3.
from ksh.
ping @JohnoKing
from ksh.
Odd that these would show up on your system but not on mine (macOS 12.6.7).
from ksh.
I can't reproduce this bug, though that's because I don't have a Mac to test on. Regarding other OSes, only Haiku and Cygwin have similar test failures, but those are pre-existing and aren't caused by #712.
from ksh.
Two systems, identical failure. On an Intel iMac and my M1 MBP. Open for ways to test further.
It passes on Kali Linux and on both of my Debian Linux test systems.
from ksh.
Below is an experimental patch that might fix the test failures. It forces ksh to use sigaction
whenever possible by calling ast_signal
without macro redefinitions (it currently doesn't have backward compatibility with the nonstandard signal
syscall).
Test Patch (apply on top of 32950af)
diff --git a/src/cmd/ksh93/bltins/trap.c b/src/cmd/ksh93/bltins/trap.c
index 5ddd44686..4bf308bca 100644
--- a/src/cmd/ksh93/bltins/trap.c
+++ b/src/cmd/ksh93/bltins/trap.c
@@ -150,7 +150,7 @@ int b_trap(int argc,char *argv[],Shbltin_t *context)
{
sh_sigclear(sig);
if(dflag)
- signal(sig,SIG_DFL);
+ ast_signal(sig,SIG_DFL);
}
else
{
diff --git a/src/cmd/ksh93/features/poll b/src/cmd/ksh93/features/poll
index 94e9fc24e..5b32abf41 100644
--- a/src/cmd/ksh93/features/poll
+++ b/src/cmd/ksh93/features/poll
@@ -56,7 +56,7 @@ tst pipe_socketpair note{ use socketpair() for peekable pipe() }end execute{
}
close(pfd[0]);
close(sfd[0]);
- signal(SIGPIPE, handler);
+ ast_signal(SIGPIPE, handler);
if (socketpair(AF_UNIX, SOCK_STREAM, 0, sfd) < 0 ||
shutdown(sfd[1], SHUT_RD) < 0 ||
shutdown(sfd[0], SHUT_WR) < 0)
diff --git a/src/cmd/ksh93/sh/fault.c b/src/cmd/ksh93/sh/fault.c
index e11de1b90..10ad923f5 100644
--- a/src/cmd/ksh93/sh/fault.c
+++ b/src/cmd/ksh93/sh/fault.c
@@ -67,7 +67,7 @@ void sh_fault(int sig)
int save_errno = errno;
/* reset handler */
if(!(sig&SH_TRAP))
- signal(sig, sh_fault);
+ ast_signal(sig, sh_fault);
sig &= ~SH_TRAP;
#ifdef SIGWINCH
if(sig==SIGWINCH)
@@ -313,16 +313,16 @@ void sh_sigtrap(int sig)
else if(!((flag=sh.sigflag[sig])&(SH_SIGFAULT|SH_SIGOFF)))
{
/* don't set signal if already set or off by parent */
- if((fun=signal(sig,sh_fault))==SIG_IGN)
+ if((fun=ast_signal(sig,sh_fault))==SIG_IGN)
{
- signal(sig,SIG_IGN);
+ ast_signal(sig,SIG_IGN);
flag |= SH_SIGOFF;
}
else
{
flag |= SH_SIGFAULT;
if(sig==SIGALRM && fun!=SIG_DFL && fun!=sh_fault)
- signal(sig,fun);
+ ast_signal(sig,fun);
}
flag &= ~(SH_SIGSET|SH_SIGTRAP);
sh.sigflag[sig] = flag;
@@ -373,7 +373,7 @@ void sh_sigreset(int mode)
else if(sig && mode>1)
{
if(sig!=SIGCHLD)
- signal(sig,SIG_IGN);
+ ast_signal(sig,SIG_IGN);
flag &= ~SH_SIGFAULT;
flag |= SH_SIGOFF;
}
@@ -705,7 +705,7 @@ noreturn void sh_done(int sig)
vlimit(RLIMIT_CORE,0);
#endif
}
- signal(sig,SIG_DFL);
+ ast_signal(sig,SIG_DFL);
sigrelease(sig);
kill(sh.current_pid,sig);
pause();
diff --git a/src/cmd/ksh93/sh/jobs.c b/src/cmd/ksh93/sh/jobs.c
index 442abe850..6ccf86c73 100644
--- a/src/cmd/ksh93/sh/jobs.c
+++ b/src/cmd/ksh93/sh/jobs.c
@@ -487,7 +487,7 @@ int job_reap(int sig)
}
sh.waitevent = waitevent;
if(sig)
- signal(sig, job_waitsafe);
+ ast_signal(sig, job_waitsafe);
/*
* Always restore errno, because this code is run during signal handling which may interrupt loops like:
* while((fd = open(path, flags, mode)) < 0)
@@ -521,7 +521,7 @@ void job_init(int lflag)
{
int ntry=0;
job.fd = JOBTTY;
- signal(SIGCHLD,job_waitsafe);
+ ast_signal(SIGCHLD,job_waitsafe);
if(njob_savelist < NJOB_SAVELIST)
init_savelist();
if(!sh_isoption(SH_INTERACTIVE))
@@ -570,7 +570,7 @@ void job_init(int lflag)
if(job.mytgid <= 0)
return;
/* Stop this shell until continued */
- signal(SIGTTIN,SIG_DFL);
+ ast_signal(SIGTTIN,SIG_DFL);
kill(sh.pid,SIGTTIN);
/* resumes here after continue tries again */
if(ntry++ > IOMAXTRY)
@@ -619,10 +619,10 @@ void job_init(int lflag)
# endif
sigflag(SIGCHLD, SA_NOCLDSTOP|SA_NOCLDWAIT, 0);
#endif /* SA_NOCLDSTOP || SA_NOCLDWAIT */
- signal(SIGTTIN,SIG_IGN);
- signal(SIGTTOU,SIG_IGN);
+ ast_signal(SIGTTIN,SIG_IGN);
+ ast_signal(SIGTTOU,SIG_IGN);
/* The shell now handles ^Z */
- signal(SIGTSTP,sh_fault);
+ ast_signal(SIGTSTP,sh_fault);
tcsetpgrp(JOBTTY,sh.pid);
#ifdef CNSUSP
/* set the switch character */
diff --git a/src/cmd/ksh93/sh/main.c b/src/cmd/ksh93/sh/main.c
index 34672a3f1..55c83d684 100644
--- a/src/cmd/ksh93/sh/main.c
+++ b/src/cmd/ksh93/sh/main.c
@@ -182,10 +182,10 @@ int sh_main(int ac, char *av[], Shinit_f userinit)
if(sh_isoption(SH_INTERACTIVE))
{
#ifdef SIGXCPU
- signal(SIGXCPU,SIG_DFL);
+ ast_signal(SIGXCPU,SIG_DFL);
#endif /* SIGXCPU */
#ifdef SIGXFSZ
- signal(SIGXFSZ,SIG_DFL);
+ ast_signal(SIGXFSZ,SIG_DFL);
#endif /* SIGXFSZ */
sh_onoption(SH_MONITOR);
}
@@ -352,7 +352,7 @@ int sh_main(int ac, char *av[], Shinit_f userinit)
/* keep $COLUMNS and $LINES up to date even for scripts that don't trap SIGWINCH */
sh_winsize(NULL,NULL);
#ifdef SIGWINCH
- signal(SIGWINCH,sh_fault);
+ ast_signal(SIGWINCH,sh_fault);
#endif /* SIGWINCH */
}
/* (Re)set PS4 and IFS, but don't export these now even if allexport is on. */
diff --git a/src/cmd/ksh93/sh/timers.c b/src/cmd/ksh93/sh/timers.c
index 5c398004f..133d98397 100644
--- a/src/cmd/ksh93/sh/timers.c
+++ b/src/cmd/ksh93/sh/timers.c
@@ -145,7 +145,7 @@ static void sigalrm(int sig)
if(tpmin && (left==0 || (tp && tpmin->wakeup < (now+left))))
{
if(left==0)
- signal(SIGALRM,sigalrm);
+ ast_signal(SIGALRM,sigalrm);
left = setalarm(tpmin->wakeup-now);
if(left && (now+left) < tpmin->wakeup)
setalarm(left);
@@ -167,7 +167,7 @@ static void sigalrm(int sig)
break;
}
if(!tpmin)
- signal(SIGALRM,(sh.sigflag[SIGALRM]&SH_SIGFAULT)?sh_fault:SIG_DFL);
+ ast_signal(SIGALRM,(sh.sigflag[SIGALRM]&SH_SIGFAULT)?sh_fault:SIG_DFL);
time_state &= ~IN_SIGALRM;
errno = EINTR;
}
@@ -201,7 +201,7 @@ void *sh_timeradd(unsigned long msec,int flags,void (*action)(void*),void *handl
if(!tpmin || tp->wakeup < tpmin->wakeup)
{
tpmin = tp;
- fn = (Handler_t)signal(SIGALRM,sigalrm);
+ fn = (Handler_t)ast_signal(SIGALRM,sigalrm);
if((t= setalarm(t))>0 && fn && fn!=(Handler_t)sigalrm)
{
Handler_t *hp = (Handler_t*)sh_malloc(sizeof(Handler_t));
@@ -240,6 +240,6 @@ void sh_timerdel(void *handle)
tpmin = 0;
setalarm((double)0);
}
- signal(SIGALRM,(sh.sigflag[SIGALRM]&SH_SIGFAULT)?sh_fault:SIG_DFL);
+ ast_signal(SIGALRM,(sh.sigflag[SIGALRM]&SH_SIGFAULT)?sh_fault:SIG_DFL);
}
}
diff --git a/src/cmd/ksh93/sh/xec.c b/src/cmd/ksh93/sh/xec.c
index 72eac72e3..3b723b075 100644
--- a/src/cmd/ksh93/sh/xec.c
+++ b/src/cmd/ksh93/sh/xec.c
@@ -1553,8 +1553,8 @@ int sh_exec(const Shnode_t *t, int flags)
if((type&FINT) && !sh_isstate(SH_MONITOR))
{
/* default std input for & */
- signal(SIGINT,SIG_IGN);
- signal(SIGQUIT,SIG_IGN);
+ ast_signal(SIGINT,SIG_IGN);
+ ast_signal(SIGQUIT,SIG_IGN);
if(!sh.st.ioset)
{
if(sh_close(0)>=0)
@@ -2837,9 +2837,9 @@ pid_t _sh_fork(pid_t parent,int flags,int *jobid)
}
if(job.jobcontrol)
{
- signal(SIGTTIN,SIG_DFL);
- signal(SIGTTOU,SIG_DFL);
- signal(SIGTSTP,SIG_DFL);
+ ast_signal(SIGTTIN,SIG_DFL);
+ ast_signal(SIGTTOU,SIG_DFL);
+ ast_signal(SIGTSTP,SIG_DFL);
}
job.jobcontrol = 0;
job.toclear = 1;
@@ -3305,7 +3305,7 @@ static void sigreset(int mode)
if(sig==SIGCHLD)
continue;
if((trap=sh.st.trapcom[sig]) && *trap==0)
- signal(sig,mode?sh_fault:SIG_IGN);
+ ast_signal(sig,mode?sh_fault:SIG_IGN);
}
}
@@ -3380,9 +3380,9 @@ static pid_t sh_ntfork(const Shnode_t *t,char *argv[],int *jobid,int topfd)
#if _use_ntfork_tcpgrp
if(job.jobcontrol)
{
- signal(SIGTTIN,SIG_DFL);
- signal(SIGTTOU,SIG_DFL);
- signal(SIGTSTP,SIG_DFL);
+ ast_signal(SIGTTIN,SIG_DFL);
+ ast_signal(SIGTTOU,SIG_DFL);
+ ast_signal(SIGTSTP,SIG_DFL);
jobwasset++;
}
if(sh_isstate(SH_MONITOR) && job.jobcontrol)
@@ -3430,12 +3430,12 @@ static pid_t sh_ntfork(const Shnode_t *t,char *argv[],int *jobid,int topfd)
#if _use_ntfork_tcpgrp
if(jobwasset)
{
- signal(SIGTTIN,SIG_IGN);
- signal(SIGTTOU,SIG_IGN);
+ ast_signal(SIGTTIN,SIG_IGN);
+ ast_signal(SIGTTOU,SIG_IGN);
if(sh_isstate(SH_INTERACTIVE))
- signal(SIGTSTP,SIG_IGN);
+ ast_signal(SIGTSTP,SIG_IGN);
else
- signal(SIGTSTP,SIG_DFL);
+ ast_signal(SIGTSTP,SIG_DFL);
}
if(job.jobcontrol)
tcsetpgrp(job.fd,sh.pid);
@@ -3465,12 +3465,12 @@ static pid_t sh_ntfork(const Shnode_t *t,char *argv[],int *jobid,int topfd)
#if _use_ntfork_tcpgrp
if(jobwasset)
{
- signal(SIGTTIN,SIG_IGN);
- signal(SIGTTOU,SIG_IGN);
+ ast_signal(SIGTTIN,SIG_IGN);
+ ast_signal(SIGTTOU,SIG_IGN);
if(sh_isstate(SH_INTERACTIVE))
- signal(SIGTSTP,SIG_IGN);
+ ast_signal(SIGTSTP,SIG_IGN);
else
- signal(SIGTSTP,SIG_DFL);
+ ast_signal(SIGTSTP,SIG_DFL);
}
#endif /* _use_ntfork_tcpgrp */
if(sigwasset)
diff --git a/src/lib/libast/comp/execve.c b/src/lib/libast/comp/execve.c
index da76ed2d2..edee477fe 100644
--- a/src/lib/libast/comp/execve.c
+++ b/src/lib/libast/comp/execve.c
@@ -35,7 +35,7 @@ static void
execsig(int sig)
{
kill(childpid, sig);
- signal(sig, execsig);
+ ast_signal(sig, execsig);
}
extern int
@@ -46,12 +46,12 @@ execve(const char* path, char* const argv[], char* const arge[])
if ((childpid = spawnve(path, argv, arge)) < 0)
return -1;
for (status = 0; status < 64; status++)
- signal(status, execsig);
+ ast_signal(status, execsig);
while (waitpid(childpid, &status, 0) == -1)
if (errno != EINTR) return -1;
if (WIFSIGNALED(status))
{
- signal(WTERMSIG(status), SIG_DFL);
+ ast_signal(WTERMSIG(status), SIG_DFL);
kill(getpid(), WTERMSIG(status));
pause();
}
diff --git a/src/lib/libast/features/lib b/src/lib/libast/features/lib
index d2a505b73..8ec8f4a5f 100644
--- a/src/lib/libast/features/lib
+++ b/src/lib/libast/features/lib
@@ -530,12 +530,6 @@ std remove note{ stuck with standard remove() }end nostatic{
int main(void) { return unlink("foo"); }
}end
-std signal note{ stuck with standard signal }end nolink{
- extern void abort(void);
- int signal(void) { return 0; }
- int main(void) { signal(); abort(); return 0; }
-}end
-
std strcoll note{ standard strcoll works }end execute{
#include <string.h>
#define S "hello world"
diff --git a/src/lib/libast/features/map.c b/src/lib/libast/features/map.c
index 0df72840c..32e46b6b6 100644
--- a/src/lib/libast/features/map.c
+++ b/src/lib/libast/features/map.c
@@ -135,11 +135,6 @@ main(void)
printf("#define glob _ast_glob\n");
printf("#undef globfree\n");
printf("#define globfree _ast_globfree\n");
-#if _map_libc || (!_std_signal && (_lib_sigaction && defined(SA_NOCLDSTOP) || _lib_sigvec && defined(SV_INTERRUPT)))
- /* use the libast signal() function (aka sigaction) when applicable */
- printf("#undef signal\n");
- printf("#define signal _ast_signal\n");
-#endif
#if _map_libc
printf("#undef memdup\n");
printf("#define memdup _ast_memdup\n");
diff --git a/src/lib/libast/features/omitted b/src/lib/libast/features/omitted
index 26f7f5c0a..1463fdc9c 100644
--- a/src/lib/libast/features/omitted
+++ b/src/lib/libast/features/omitted
@@ -97,7 +97,7 @@ tst win32_botch_alarm note{ Win32 alarm(2) return botched }end noexecute{
int
main(int argc, char** argv)
{
- signal(SIGALRM, handler);
+ ast_signal(SIGALRM, handler);
alarm(2);
pause();
return sigalrm != 1 || alarm(0) != 0;
diff --git a/src/lib/libast/features/sig.sh b/src/lib/libast/features/sig.sh
index 9c3c56dc3..ff5d8dd87 100644
--- a/src/lib/libast/features/sig.sh
+++ b/src/lib/libast/features/sig.sh
@@ -106,4 +106,4 @@ extern int sigflag(int, int, int);
#endif
extern int sigcritical(int);
extern int sigunblock(int);
-extern Sig_handler_t _ast_signal(int, Sig_handler_t);'
+extern Sig_handler_t ast_signal(int, Sig_handler_t);'
diff --git a/src/lib/libast/misc/error.c b/src/lib/libast/misc/error.c
index 07f4497d6..a53861242 100644
--- a/src/lib/libast/misc/error.c
+++ b/src/lib/libast/misc/error.c
@@ -579,7 +579,7 @@ errorv(const char* id, int level, va_list ap)
#endif
#endif
#ifdef SIGABRT
- signal(SIGABRT, SIG_DFL);
+ ast_signal(SIGABRT, SIG_DFL);
kill(getpid(), SIGABRT);
pause();
#else
diff --git a/src/lib/libast/misc/procclose.c b/src/lib/libast/misc/procclose.c
index 2559b1458..e5cc1cfaa 100644
--- a/src/lib/libast/misc/procclose.c
+++ b/src/lib/libast/misc/procclose.c
@@ -64,16 +64,16 @@ procclose(Proc_t* p)
else
{
if (p->sigint != SIG_IGN)
- signal(SIGINT, p->sigint);
+ ast_signal(SIGINT, p->sigint);
if (p->sigquit != SIG_IGN)
- signal(SIGQUIT, p->sigquit);
+ ast_signal(SIGQUIT, p->sigquit);
#if _lib_sigprocmask
sigprocmask(SIG_SETMASK, &p->mask, NULL);
#elif _lib_sigsetmask
sigsetmask(p->mask);
#else
if (p->sigchld != SIG_DFL)
- signal(SIGCHLD, p->sigchld);
+ ast_signal(SIGCHLD, p->sigchld);
#endif
}
status = status == -1 ?
diff --git a/src/lib/libast/misc/procopen.c b/src/lib/libast/misc/procopen.c
index 5cecfd22b..cf6017933 100644
--- a/src/lib/libast/misc/procopen.c
+++ b/src/lib/libast/misc/procopen.c
@@ -148,7 +148,7 @@ typedef struct Mod_s
static void
ignoresig(int sig)
{
- signal(sig, ignoresig);
+ ast_signal(sig, ignoresig);
}
/*
@@ -207,10 +207,10 @@ modify(Proc_t* proc, int forked, int op, long arg1, long arg2)
close(arg2);
break;
case PROC_sig_dfl:
- signal(arg1, SIG_DFL);
+ ast_signal(arg1, SIG_DFL);
break;
case PROC_sig_ign:
- signal(arg1, SIG_IGN);
+ ast_signal(arg1, SIG_IGN);
break;
case PROC_sys_pgrp:
if (arg1 < 0)
@@ -280,12 +280,12 @@ modify(Proc_t* proc, int forked, int op, long arg1, long arg2)
}
break;
case PROC_sig_dfl:
- if ((m->arg.handler = signal(arg1, SIG_DFL)) == SIG_DFL)
+ if ((m->arg.handler = ast_signal(arg1, SIG_DFL)) == SIG_DFL)
break;
m->save = (short)arg1;
return 0;
case PROC_sig_ign:
- if ((m->arg.handler = signal(arg1, SIG_IGN)) == SIG_IGN)
+ if ((m->arg.handler = ast_signal(arg1, SIG_IGN)) == SIG_IGN)
break;
m->save = (short)arg1;
return 0;
@@ -359,7 +359,7 @@ restore(Proc_t* proc)
break;
case PROC_sig_dfl:
case PROC_sig_ign:
- signal(m->save, m->arg.handler);
+ ast_signal(m->save, m->arg.handler);
break;
case PROC_sys_umask:
umask(m->save);
@@ -496,8 +496,8 @@ procopen(const char* cmd, char** argv, char** envv, long* modv, int flags)
else
{
signalled = 1;
- proc->sigint = signal(SIGINT, SIG_IGN);
- proc->sigquit = signal(SIGQUIT, SIG_IGN);
+ proc->sigint = ast_signal(SIGINT, SIG_IGN);
+ proc->sigquit = ast_signal(SIGQUIT, SIG_IGN);
#if _lib_sigprocmask
sigemptyset(&mask);
sigaddset(&mask, SIGCHLD);
@@ -506,7 +506,7 @@ procopen(const char* cmd, char** argv, char** envv, long* modv, int flags)
mask = sigmask(SIGCHLD);
proc->mask = sigblock(mask);
#else
- proc->sigchld = signal(SIGCHLD, SIG_DFL);
+ proc->sigchld = ast_signal(SIGCHLD, SIG_DFL);
#endif /* _lib_sigprocmask */
}
if ((flags & PROC_ORPHAN) && pipe(pop))
@@ -519,12 +519,12 @@ procopen(const char* cmd, char** argv, char** envv, long* modv, int flags)
if (proc->sigint != SIG_IGN)
{
proc->sigint = SIG_DFL;
- signal(SIGINT, proc->sigint);
+ ast_signal(SIGINT, proc->sigint);
}
if (proc->sigquit != SIG_IGN)
{
proc->sigquit = SIG_DFL;
- signal(SIGQUIT, proc->sigquit);
+ ast_signal(SIGQUIT, proc->sigquit);
}
#if _lib_sigprocmask
sigprocmask(SIG_SETMASK, &proc->mask, NULL);
@@ -532,7 +532,7 @@ procopen(const char* cmd, char** argv, char** envv, long* modv, int flags)
sigsetmask(proc->mask);
#else
if (proc->sigchld != SIG_IGN)
- signal(SIGCHLD, SIG_DFL);
+ ast_signal(SIGCHLD, SIG_DFL);
#endif /* _lib_sigprocmask */
}
else if (proc->pid == -1)
@@ -758,8 +758,8 @@ procopen(const char* cmd, char** argv, char** envv, long* modv, int flags)
if (flags & PROC_FOREGROUND)
{
signalled = 1;
- proc->sigint = signal(SIGINT, SIG_IGN);
- proc->sigquit = signal(SIGQUIT, SIG_IGN);
+ proc->sigint = ast_signal(SIGINT, SIG_IGN);
+ proc->sigquit = ast_signal(SIGQUIT, SIG_IGN);
#if _lib_sigprocmask
sigemptyset(&mask);
sigaddset(&mask, SIGCHLD);
@@ -768,7 +768,7 @@ procopen(const char* cmd, char** argv, char** envv, long* modv, int flags)
mask = sigmask(SIGCHLD);
proc->mask = sigblock(mask);
#else
- proc->sigchld = signal(SIGCHLD, SIG_DFL);
+ proc->sigchld = ast_signal(SIGCHLD, SIG_DFL);
#endif /* _lib_sigprocmask */
}
}
@@ -798,8 +798,8 @@ procopen(const char* cmd, char** argv, char** envv, long* modv, int flags)
{
Handler_t handler;
- if ((handler = signal(SIGPIPE, ignoresig)) != SIG_DFL && handler != ignoresig)
- signal(SIGPIPE, handler);
+ if ((handler = ast_signal(SIGPIPE, ignoresig)) != SIG_DFL && handler != ignoresig)
+ ast_signal(SIGPIPE, handler);
}
switch (procfd)
{
@@ -840,16 +840,16 @@ procopen(const char* cmd, char** argv, char** envv, long* modv, int flags)
if (signalled)
{
if (proc->sigint != SIG_IGN)
- signal(SIGINT, proc->sigint);
+ ast_signal(SIGINT, proc->sigint);
if (proc->sigquit != SIG_IGN)
- signal(SIGQUIT, proc->sigquit);
+ ast_signal(SIGQUIT, proc->sigquit);
#if _lib_sigprocmask
sigprocmask(SIG_SETMASK, &proc->mask, NULL);
#elif _lib_sigsetmask
sigsetmask(proc->mask);
#else
if (proc->sigchld != SIG_DFL)
- signal(SIGCHLD, proc->sigchld);
+ ast_signal(SIGCHLD, proc->sigchld);
#endif /* _lib_sigprocmask */
}
if ((flags & PROC_CLEANUP) && modv)
diff --git a/src/lib/libast/misc/sigcrit.c b/src/lib/libast/misc/sigcrit.c
index 4cc14046c..ca04c7f3e 100644
--- a/src/lib/libast/misc/sigcrit.c
+++ b/src/lib/libast/misc/sigcrit.c
@@ -58,7 +58,7 @@ static long hold; /* held signal mask */
static void
interrupt(int sig)
{
- signal(sig, interrupt);
+ ast_signal(sig, interrupt);
hold |= sigmask(sig);
}
@@ -114,9 +114,9 @@ sigcritical(int op)
#else
hold = 0;
for (i = 0; i < elementsof(signals); i++)
- if ((op & signals[i].op) && (handler[i] = signal(signals[i].sig, interrupt)) == SIG_IGN)
+ if ((op & signals[i].op) && (handler[i] = ast_signal(signals[i].sig, interrupt)) == SIG_IGN)
{
- signal(signals[i].sig, handler[i]);
+ ast_signal(signals[i].sig, handler[i]);
hold &= ~sigmask(signals[i].sig);
}
#endif
@@ -162,7 +162,7 @@ sigcritical(int op)
#else
for (i = 0; i < elementsof(signals); i++)
if (region & signals[i].op)
- signal(signals[i].sig, handler[i]);
+ ast_signal(signals[i].sig, handler[i]);
if (hold)
{
for (i = 0; i < elementsof(signals); i++)
diff --git a/src/lib/libast/misc/signal.c b/src/lib/libast/misc/signal.c
index 36e47a28d..5578d91ea 100644
--- a/src/lib/libast/misc/signal.c
+++ b/src/lib/libast/misc/signal.c
@@ -34,7 +34,7 @@
#define SV_INTERRUPT SV_ABORT
#endif
-#if !_std_signal && (_lib_sigaction && defined(SA_NOCLDSTOP) || _lib_sigvec && defined(SV_INTERRUPT))
+#if _lib_sigaction && defined(SA_NOCLDSTOP) || _lib_sigvec && defined(SV_INTERRUPT)
#if !defined(SA_NOCLDSTOP) || !defined(SA_INTERRUPT) && defined(SV_INTERRUPT)
#undef SA_INTERRUPT
@@ -52,7 +52,7 @@
#endif
Sig_handler_t
-signal(int sig, Sig_handler_t fun)
+ast_signal(int sig, Sig_handler_t fun)
{
struct sigaction na;
struct sigaction oa;
@@ -103,6 +103,6 @@ signal(int sig, Sig_handler_t fun)
#else
-NoN(signal)
+#error "POSIX sigaction not detected"
#endif
diff --git a/src/lib/libast/sfio/sfmode.c b/src/lib/libast/sfio/sfmode.c
index d028c7114..6985129ec 100644
--- a/src/lib/libast/sfio/sfmode.c
+++ b/src/lib/libast/sfio/sfmode.c
@@ -193,8 +193,8 @@ int _sfpopen(Sfio_t* f, int fd, int pid, int stdio) /* stdio popen() does not re
if(p->sigp)
{ Sfsignal_f handler;
- if((handler = signal(SIGPIPE, SIG_IGN)) != SIG_DFL && handler != SIG_IGN)
- signal(SIGPIPE, handler); /* honor user handler */
+ if((handler = ast_signal(SIGPIPE, SIG_IGN)) != SIG_DFL && handler != SIG_IGN)
+ ast_signal(SIGPIPE, handler); /* honor user handler */
_Sfsigp += 1;
}
@@ -233,8 +233,8 @@ int _sfpclose(Sfio_t* f)
sigcritical(0);
if(p->sigp && (_Sfsigp -= 1) <= 0)
{ Sfsignal_f handler;
- if((handler = signal(SIGPIPE,SIG_DFL)) != SIG_DFL && handler != SIG_IGN)
- signal(SIGPIPE,handler); /* honor user handler */
+ if((handler = ast_signal(SIGPIPE,SIG_DFL)) != SIG_DFL && handler != SIG_IGN)
+ ast_signal(SIGPIPE,handler); /* honor user handler */
_Sfsigp = 0;
}
}
diff --git a/src/lib/libast/vmalloc/vmbest.c b/src/lib/libast/vmalloc/vmbest.c
index f0f1c435f..cc48aa461 100644
--- a/src/lib/libast/vmalloc/vmbest.c
+++ b/src/lib/libast/vmalloc/vmbest.c
@@ -1026,12 +1026,12 @@ static int chkaddr(Vmuchar_t* addr, size_t nsize)
int rv;
Gotsegv = 0; /* catch segment fault */
- segv = signal(SIGSEGV, sigsegv);
+ segv = ast_signal(SIGSEGV, sigsegv);
rv = *(addr+nsize-1);
rv = Gotsegv ? -1 : rv;
- signal(SIGSEGV, segv); /* restore signal catcher */
+ ast_signal(SIGSEGV, segv); /* restore signal catcher */
Gotsegv = 0;
return rv;
diff --git a/src/lib/libcmd/tee.c b/src/lib/libcmd/tee.c
index 6399e71f7..22d7e7baf 100644
--- a/src/lib/libcmd/tee.c
+++ b/src/lib/libcmd/tee.c
@@ -132,7 +132,7 @@ b_tee(int argc, char** argv, Shbltin_t* context)
oflag |= O_APPEND;
continue;
case 'i':
- signal(SIGINT, SIG_IGN);
+ ast_signal(SIGINT, SIG_IGN);
continue;
case 'l':
line = sfset(sfstdout, 0, 0) & SF_LINE;
@@ -160,7 +160,7 @@ b_tee(int argc, char** argv, Shbltin_t* context)
#if _ANCIENT_BSD_COMPATIBILITY
if (*argv && streq(*argv, "-"))
{
- signal(SIGINT, SIG_IGN);
+ ast_signal(SIGINT, SIG_IGN);
argv++;
argc--;
}
from ksh.
Actually, it might just be a bug in the libast Mamfile. The following sequence of commands is enough to cause two io test failures on Linux:
$ git clean -fdx
$ git checkout 2bcadf773 # Prior commit without _ast_signal change
$ bin/package make
$ git checkout 32950afe96 # _ast_signal commit
$ bin/package make
$ bin/shtests io
#### Regression-testing /home/johno/GitRepos/KornShell/ksh/arch/linux.i386-64/bin/ksh ####
test io begins at 2024-02-09+08:47:22
io.sh[353]: FAIL: read -n3 from fifo failed -- expected 'a', got 'abc'
io.sh[356]: FAIL: read -n1 from fifo failed -- expected 'b', got 'd'
test io failed at 2024-02-09+08:47:23 with exit code 2 [ 166 tests 2 errors ]
test io(C.UTF-8) begins at 2024-02-09+08:47:23
io.sh[353]: FAIL: read -n3 from fifo failed -- expected 'a', got 'abc'
io.sh[356]: FAIL: read -n1 from fifo failed -- expected 'b', got 'd'
test io(C.UTF-8) failed at 2024-02-09+08:47:25 with exit code 2 [ 166 tests 2 errors ]
test io(shcomp) begins at 2024-02-09+08:47:25
shcomp-io.ksh[353]: FAIL: read -n3 from fifo failed -- expected 'a', got 'abc'
shcomp-io.ksh[356]: FAIL: read -n1 from fifo failed -- expected 'b', got 'd'
test io(shcomp) failed at 2024-02-09+08:47:27 with exit code 2 [ 166 tests 2 errors ]
Total errors: 6
Removing the build directory with git clean -fdx
before building the latest commit avoids the io.sh test failures on Linux.
from ksh.
Still fails on macOS with git clean -fdx
beforehand.
from ksh.
I must need more coffee, I can't get the patch from #719 (comment) to apply.
$ git apply --stat sigaction.patch
src/cmd/ksh93/bltins/trap.c | 2 +-
src/cmd/ksh93/features/poll | 2 +-
src/cmd/ksh93/sh/fault.c | 12 ++++++------
src/cmd/ksh93/sh/jobs.c | 12 ++++++------
src/cmd/ksh93/sh/main.c | 6 +++---
src/cmd/ksh93/sh/timers.c | 8 ++++----
src/cmd/ksh93/sh/xec.c | 34 +++++++++++++++++----------------
src/lib/libast/comp/execve.c | 6 +++---
src/lib/libast/features/lib | 6 ------
src/lib/libast/features/map.c | 5 -----
src/lib/libast/features/omitted | 2 +-
src/lib/libast/features/sig.sh | 2 +-
src/lib/libast/misc/error.c | 2 +-
src/lib/libast/misc/procclose.c | 6 +++---
src/lib/libast/misc/procopen.c | 40 ++++++++++++++++++++-------------------
src/lib/libast/misc/sigcrit.c | 8 ++++----
src/lib/libast/misc/signal.c | 6 +++---
src/lib/libast/sfio/sfmode.c | 8 ++++----
src/lib/libast/vmalloc/vmbest.c | 4 ++--
src/lib/libcmd/tee.c | 4 ++--
20 files changed, 82 insertions(+), 93 deletions(-)
[ 9:36 AM][ttys000 +1][~/src/ksh-io][dev@32950afe]
$
But...
$ git apply < sigaction.patch
error: patch failed: src/cmd/ksh93/bltins/trap.c:150
error: src/cmd/ksh93/bltins/trap.c: patch does not apply
error: patch failed: src/cmd/ksh93/features/poll:56
...
error: src/lib/libast/vmalloc/vmbest.c: patch does not apply
error: patch failed: src/lib/libcmd/tee.c:132
error: src/lib/libcmd/tee.c: patch does not apply
[ 9:39 AM][ttys000 +1][~/src/ksh-io][dev@32950afe]
$
from ksh.
Actually, it might just be a bug in the libast Mamfile. The following sequence of commands is enough to cause two io test failures on Linux:
I can reproduce these failures on macOS 12.6.7 using your recipe.
from ksh.
And after deleting the entire build directory and rebuilding with the current commit (note: do not use git clean -fdx
unless you also want all non-repo files outside of your build directory deleted!) I can now reproduce all the regression test failures that @posguy99 reported.
Maybe there is a bug in libast/Mamfile, but then that bug was causing the regression test failures to fail to show up without rebuilding from scratch.
I'm going to revert that commit for now. More research is needed, but I haven't a clue where to start looking yet and I'm afraid my priorities are really elsewhere right now.
from ksh.
Maybe there is a bug in libast/Mamfile, but then that bug was causing the regression test failures to fail to show up without rebuilding from scratch.
It's also causing the regression test failures to fail to go away after reverting the commit. This is not good.
from ksh.
The regression test failures go away (after reverting the commit)/reappear (after reinstating the commit) when doing the following:
$ touch src/cmd/ksh93/features/poll
...and rebuilding.
This means the buggy commit affects the result of that feature test.
from ksh.
Diff between the features/poll
test results with and without the offending commit:
$ diff 1 2
33c33
< iffe: test: use socketpair() for peekable pipe() ... no
---
> iffe: test: use socketpair() for peekable pipe() ... yes
So, it's the pipe_socketpair
feature test that's affected by it.
ksh/src/cmd/ksh93/features/poll
Lines 8 to 68 in 5948b42
from ksh.
So, here is the cause of the bug -- compiling with the offending commit, rerunning the pipe_socketpair test with IFFEFLAGS=-d1
:
iffe: test: use socketpair() for peekable pipe() ...
+ cc -O0 -g -Wall -I/usr/local/src/ksh93/ksh/arch/darwin.arm64-64/include/ast -I/usr/local/src/ksh93/ksh/arch/darwin.arm64-64/include '-DTEST=' '-DID=pipe_socketpair' -o ./grey80031.exe ./grey80031.c /usr/local/src/ksh93/ksh/arch/darwin.arm64-64/lib/libdll.a /usr/local/src/ksh93/ksh/arch/darwin.arm64-64/lib/libast.a -liconv -liconv /usr/local/src/ksh93/ksh/arch/darwin.arm64-64/lib/libcmd.a /usr/local/src/ksh93/ksh/arch/darwin.arm64-64/lib/libast.a -liconv -liconv -lutil /usr/local/src/ksh93/ksh/arch/darwin.arm64-64/lib/libast.a -liconv
./grey80031.c:98:2: error: implicit declaration of function '_ast_signal' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
signal(SIGPIPE, handler);
^
/usr/local/src/ksh93/ksh/arch/darwin.arm64-64/include/ast/ast_map.h:18:22: note: expanded from macro 'signal'
#define signal _ast_signal
^
1 error generated.
iffe: ... no
from ksh.
Related Issues (20)
- open file descriptors of the shell aren't inherited by processes launched by the shell, unlike bash or zsh HOT 5
- `sleep 10 | read` hangs interactive shell after ^Z HOT 3
- document shell option behavior wrt functions HOT 3
- showme doesn't print redirects properly HOT 1
- e8b45cc8 Broke FreeBSD Build HOT 5
- Cygwin //server/path paths do not work HOT 3
- ksh93 1.0.9 build crashes on Cygwin 3.5.3 HOT 20
- RFE: Add build option to run mamake/mamprobe/iffe under valgrind control HOT 2
- [portability] Make AST code aliasing clean and use -fstrict-aliasing with ISO C17 aliasing rules HOT 2
- support HISTCONTROL as in bash HOT 3
- ksh93's printf(1) builtin somehow turns "\x20" (space character in UTF-8) into garbage HOT 10
- Syntax error in arithmetic command crashes ksh HOT 11
- ksh dev@3b33b438 fails signal regression test on macOS 13.6.7 Intel and ARM HOT 3
- [question] should "printf -v%s x" print "-vx" ? HOT 1
- Division by negative numbers returns "division by zero" HOT 10
- Shell arithmetic is broken for integer values beyond the system's maximum float precision HOT 5
- ksh dev@4467eaff does not build on macOS Intel/ARM 13.6.8 HOT 8
- command substitution here-doc syntax error not entered in history
- Issue with ksh93 on OpenBSD HOT 12
- Migrate code to C99 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ksh.