Move dc(1) from legacy sigset(3) to sigaction(2)
This commit is contained in:
parent
68a2eff733
commit
b00b6a04fa
6
README
6
README
|
@ -1,9 +1,11 @@
|
||||||
Heirloom bc & dc provides a stand-alone project of the Heirloom Project
|
Heirloom bc & dc provides a stand-alone project of the Heirloom Project
|
||||||
versions of bc(1) and dc(1) with simpler build system and no unnecessary
|
versions of bc(1) and dc(1) with simpler build system and no unnecessary
|
||||||
compatibility layers.
|
compatibility layers. The code has been modernized as needed to get it
|
||||||
|
working, but otherwise stays close to the original Heirloom Project
|
||||||
|
sources.
|
||||||
|
|
||||||
At the moment the code compiles and appears to run correctly with Glibc
|
At the moment the code compiles and appears to run correctly with Glibc
|
||||||
and Musl under Linux.
|
and Musl under Linux as well as Sortix.
|
||||||
|
|
||||||
The code contains parts licensed under both 4BSD and zlib licenses. See
|
The code contains parts licensed under both 4BSD and zlib licenses. See
|
||||||
the COPYING file in the relevant subdirectory for more details.
|
the COPYING file in the relevant subdirectory for more details.
|
||||||
|
|
19
dc/dc.c
19
dc/dc.c
|
@ -934,9 +934,13 @@ void
|
||||||
init(int argc,char **argv)
|
init(int argc,char **argv)
|
||||||
{
|
{
|
||||||
register struct sym *sp;
|
register struct sym *sp;
|
||||||
|
struct sigaction sa;
|
||||||
|
|
||||||
if (sigset(SIGINT, SIG_IGN) != SIG_IGN)
|
sigaction(SIGINT, NULL, &sa);
|
||||||
sigset(SIGINT,onintr);
|
if (sa.sa_handler != SIG_IGN){
|
||||||
|
sa.sa_handler = onintr;
|
||||||
|
sigaction(SIGINT, &sa, NULL);
|
||||||
|
}
|
||||||
setbuf(stdout,(char *)NULL);
|
setbuf(stdout,(char *)NULL);
|
||||||
svargc = --argc;
|
svargc = --argc;
|
||||||
svargv = argv;
|
svargv = argv;
|
||||||
|
@ -990,8 +994,6 @@ init(int argc,char **argv)
|
||||||
|
|
||||||
void
|
void
|
||||||
onintr(int signum){
|
onintr(int signum){
|
||||||
|
|
||||||
sigset(SIGINT,onintr);
|
|
||||||
while(readptr != &readstk[0]){
|
while(readptr != &readstk[0]){
|
||||||
if(*readptr != 0){release(*readptr);}
|
if(*readptr != 0){release(*readptr);}
|
||||||
readptr--;
|
readptr--;
|
||||||
|
@ -1644,7 +1646,7 @@ command(void){
|
||||||
static char *line;
|
static char *line;
|
||||||
static int linesize;
|
static int linesize;
|
||||||
char *sl;
|
char *sl;
|
||||||
register void (*savint)(int);
|
struct sigaction sa,savint;
|
||||||
register int pid,rpid;
|
register int pid,rpid;
|
||||||
int retcode;
|
int retcode;
|
||||||
|
|
||||||
|
@ -1673,9 +1675,12 @@ command(void){
|
||||||
execl("/bin/sh","sh","-c",line,NULL);
|
execl("/bin/sh","sh","-c",line,NULL);
|
||||||
exit(0100);
|
exit(0100);
|
||||||
}
|
}
|
||||||
savint = sigset(SIGINT, SIG_IGN);
|
sa.sa_flags = 0;
|
||||||
|
sigemptyset(&sa.sa_mask);
|
||||||
|
sa.sa_handler = SIG_IGN;
|
||||||
|
sigaction(SIGINT, &sa, &savint);
|
||||||
while((rpid = wait(&retcode)) != pid && rpid != -1);
|
while((rpid = wait(&retcode)) != pid && rpid != -1);
|
||||||
sigset(SIGINT,savint);
|
sigaction(SIGINT, &savint, NULL);
|
||||||
printf("!\n");
|
printf("!\n");
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue