aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2018-03-01 11:18:33 +0000
committerRon Yorston <rmy@pobox.com>2018-03-01 11:18:33 +0000
commit5f8dac68690e92f0be220f8f8d9f797a2aedc806 (patch)
tree28c1d611ace374f615cac23415b35b2ab54059f4
parent701a8d6783f09597e1c9b386b1e6ba890807854c (diff)
downloadbusybox-w32-5f8dac68690e92f0be220f8f8d9f797a2aedc806.tar.gz
busybox-w32-5f8dac68690e92f0be220f8f8d9f797a2aedc806.tar.bz2
busybox-w32-5f8dac68690e92f0be220f8f8d9f797a2aedc806.zip
Remove fake signal-handling code
Microsoft Windows has only limited support for signals. busybox-w32 initially papered over this fact by adding definitions for unsupported signals and signal-handling functions. Remove this fake code and deal with the consequences by excluding anything that fails to compile as a result.
-rw-r--r--archival/tar.c2
-rw-r--r--coreutils/tee.c2
-rw-r--r--include/libbb.h18
-rw-r--r--include/mingw.h28
-rw-r--r--libbb/Kbuild.src2
-rw-r--r--networking/nc.c4
-rw-r--r--procps/kill.c2
-rw-r--r--shell/ash.c13
8 files changed, 39 insertions, 32 deletions
diff --git a/archival/tar.c b/archival/tar.c
index 990755429..fbe5e3be8 100644
--- a/archival/tar.c
+++ b/archival/tar.c
@@ -1117,7 +1117,9 @@ int tar_main(int argc UNUSED_PARAM, char **argv)
1117 1117
1118 if (opt & OPT_2COMMAND) { 1118 if (opt & OPT_2COMMAND) {
1119 putenv((char*)"TAR_FILETYPE=f"); 1119 putenv((char*)"TAR_FILETYPE=f");
1120#ifdef SIGPIPE
1120 signal(SIGPIPE, SIG_IGN); 1121 signal(SIGPIPE, SIG_IGN);
1122#endif
1121 tar_handle->action_data = data_extract_to_command; 1123 tar_handle->action_data = data_extract_to_command;
1122 IF_FEATURE_TAR_TO_COMMAND(tar_handle->tar__to_command_shell = xstrdup(get_shell_name());) 1124 IF_FEATURE_TAR_TO_COMMAND(tar_handle->tar__to_command_shell = xstrdup(get_shell_name());)
1123 } 1125 }
diff --git a/coreutils/tee.c b/coreutils/tee.c
index f0ec791bb..d0ded58c4 100644
--- a/coreutils/tee.c
+++ b/coreutils/tee.c
@@ -69,9 +69,11 @@ int tee_main(int argc, char **argv)
69 signal(SIGINT, SIG_IGN); /* TODO - switch to sigaction. (why?) */ 69 signal(SIGINT, SIG_IGN); /* TODO - switch to sigaction. (why?) */
70 } 70 }
71 retval = EXIT_SUCCESS; 71 retval = EXIT_SUCCESS;
72#ifdef SIGPIPE
72 /* gnu tee ignores SIGPIPE in case one of the output files is a pipe 73 /* gnu tee ignores SIGPIPE in case one of the output files is a pipe
73 * that doesn't consume all its input. Good idea... */ 74 * that doesn't consume all its input. Good idea... */
74 signal(SIGPIPE, SIG_IGN); 75 signal(SIGPIPE, SIG_IGN);
76#endif
75 77
76 /* Allocate an array of FILE *'s, with one extra for a sentinel. */ 78 /* Allocate an array of FILE *'s, with one extra for a sentinel. */
77 fp = files = xzalloc(sizeof(FILE *) * (argc + 2)); 79 fp = files = xzalloc(sizeof(FILE *) * (argc + 2));
diff --git a/include/libbb.h b/include/libbb.h
index 761370111..4a59ee7d8 100644
--- a/include/libbb.h
+++ b/include/libbb.h
@@ -526,18 +526,36 @@ enum {
526 * Dance around with long long to guard against that... 526 * Dance around with long long to guard against that...
527 */ 527 */
528 BB_FATAL_SIGS = (int)(0 528 BB_FATAL_SIGS = (int)(0
529#ifdef SIGHUP
529 + (1LL << SIGHUP) 530 + (1LL << SIGHUP)
531#endif
530 + (1LL << SIGINT) 532 + (1LL << SIGINT)
531 + (1LL << SIGTERM) 533 + (1LL << SIGTERM)
534#ifdef SIGPIPE
532 + (1LL << SIGPIPE) // Write to pipe with no readers 535 + (1LL << SIGPIPE) // Write to pipe with no readers
536#endif
537#ifdef SIGQUIT
533 + (1LL << SIGQUIT) // Quit from keyboard 538 + (1LL << SIGQUIT) // Quit from keyboard
539#endif
534 + (1LL << SIGABRT) // Abort signal from abort(3) 540 + (1LL << SIGABRT) // Abort signal from abort(3)
541#ifdef SIGALRM
535 + (1LL << SIGALRM) // Timer signal from alarm(2) 542 + (1LL << SIGALRM) // Timer signal from alarm(2)
543#endif
544#ifdef SIGVTALRM
536 + (1LL << SIGVTALRM) // Virtual alarm clock 545 + (1LL << SIGVTALRM) // Virtual alarm clock
546#endif
547#ifdef SIGXCPU
537 + (1LL << SIGXCPU) // CPU time limit exceeded 548 + (1LL << SIGXCPU) // CPU time limit exceeded
549#endif
550#ifdef SIGXFSZ
538 + (1LL << SIGXFSZ) // File size limit exceeded 551 + (1LL << SIGXFSZ) // File size limit exceeded
552#endif
553#ifdef SIGUSR1
539 + (1LL << SIGUSR1) // Yes kids, these are also fatal! 554 + (1LL << SIGUSR1) // Yes kids, these are also fatal!
555#endif
556#ifdef SIGUSR1
540 + (1LL << SIGUSR2) 557 + (1LL << SIGUSR2)
558#endif
541 + 0), 559 + 0),
542}; 560};
543#if !ENABLE_PLATFORM_MINGW32 561#if !ENABLE_PLATFORM_MINGW32
diff --git a/include/mingw.h b/include/mingw.h
index c662f4baf..1bb2032cd 100644
--- a/include/mingw.h
+++ b/include/mingw.h
@@ -90,39 +90,11 @@ IMPL(getpwent,struct passwd *,NULL,void)
90/* 90/*
91 * signal.h 91 * signal.h
92 */ 92 */
93#define SIGHUP 1
94#define SIGQUIT 3
95#define SIGKILL 9 93#define SIGKILL 9
96#define SIGUSR1 10
97#define SIGUSR2 12
98#define SIGPIPE 13
99#define SIGALRM 14
100#define SIGCHLD 17
101#define SIGCONT 18
102#define SIGSTOP 19
103#define SIGTSTP 20
104#define SIGTTIN 21
105#define SIGTTOU 22
106#define SIGXCPU 24
107#define SIGXFSZ 25
108#define SIGVTALRM 26
109#define SIGWINCH 28
110 94
111#define SIG_UNBLOCK 1 95#define SIG_UNBLOCK 1
112 96
113typedef void (__cdecl *sighandler_t)(int);
114struct sigaction {
115 sighandler_t sa_handler;
116 unsigned sa_flags;
117 int sa_mask;
118};
119#define sigemptyset(x) (void)0
120#define SA_RESTART 0
121
122NOIMPL(sigaction,int sig UNUSED_PARAM, struct sigaction *in UNUSED_PARAM, struct sigaction *out UNUSED_PARAM);
123NOIMPL(sigfillset,int *mask UNUSED_PARAM);
124NOIMPL(FAST_FUNC sigprocmask_allsigs, int how UNUSED_PARAM); 97NOIMPL(FAST_FUNC sigprocmask_allsigs, int how UNUSED_PARAM);
125NOIMPL(FAST_FUNC sigaction_set,int signo UNUSED_PARAM, const struct sigaction *sa UNUSED_PARAM);
126 98
127/* 99/*
128 * stdio.h 100 * stdio.h
diff --git a/libbb/Kbuild.src b/libbb/Kbuild.src
index c0cc2baf5..4b838ab7a 100644
--- a/libbb/Kbuild.src
+++ b/libbb/Kbuild.src
@@ -12,7 +12,6 @@ INSERT
12 12
13lib-y += appletlib.o 13lib-y += appletlib.o
14lib-y += ask_confirmation.o 14lib-y += ask_confirmation.o
15lib-y += bb_askpass.o
16lib-y += bb_bswap_64.o 15lib-y += bb_bswap_64.o
17lib-y += bb_do_delay.o 16lib-y += bb_do_delay.o
18lib-y += bb_pwd.o 17lib-y += bb_pwd.o
@@ -105,6 +104,7 @@ lib-y += xgetcwd.o
105lib-y += xreadlink.o 104lib-y += xreadlink.o
106lib-y += xrealloc_vector.o 105lib-y += xrealloc_vector.o
107 106
107lib-$(CONFIG_PLATFORM_POSIX) += bb_askpass.o
108lib-$(CONFIG_PLATFORM_POSIX) += get_console.o 108lib-$(CONFIG_PLATFORM_POSIX) += get_console.o
109lib-$(CONFIG_PLATFORM_POSIX) += getpty.o 109lib-$(CONFIG_PLATFORM_POSIX) += getpty.o
110lib-$(CONFIG_PLATFORM_POSIX) += inet_common.o 110lib-$(CONFIG_PLATFORM_POSIX) += inet_common.o
diff --git a/networking/nc.c b/networking/nc.c
index de02ccc9d..3e122b787 100644
--- a/networking/nc.c
+++ b/networking/nc.c
@@ -110,10 +110,12 @@
110 * when compared to "standard" nc 110 * when compared to "standard" nc
111 */ 111 */
112 112
113#if ENABLE_NC_EXTRA
113static void timeout(int signum UNUSED_PARAM) 114static void timeout(int signum UNUSED_PARAM)
114{ 115{
115 bb_error_msg_and_die("timed out"); 116 bb_error_msg_and_die("timed out");
116} 117}
118#endif
117 119
118int nc_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; 120int nc_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
119int nc_main(int argc, char **argv) 121int nc_main(int argc, char **argv)
@@ -187,10 +189,12 @@ int nc_main(int argc, char **argv)
187 argv++; 189 argv++;
188 } 190 }
189 191
192#if ENABLE_NC_EXTRA
190 if (wsecs) { 193 if (wsecs) {
191 signal(SIGALRM, timeout); 194 signal(SIGALRM, timeout);
192 alarm(wsecs); 195 alarm(wsecs);
193 } 196 }
197#endif
194 198
195 if (!cfd) { 199 if (!cfd) {
196 if (do_listen) { 200 if (do_listen) {
diff --git a/procps/kill.c b/procps/kill.c
index c95afb8b3..4477dedb7 100644
--- a/procps/kill.c
+++ b/procps/kill.c
@@ -207,6 +207,7 @@ int kill_main(int argc UNUSED_PARAM, char **argv)
207 do_it_now: 207 do_it_now:
208 pid = getpid(); 208 pid = getpid();
209 209
210#if ENABLE_KILLALL5
210 if (is_killall5) { 211 if (is_killall5) {
211 pid_t sid; 212 pid_t sid;
212 procps_status_t* p = NULL; 213 procps_status_t* p = NULL;
@@ -264,6 +265,7 @@ int kill_main(int argc UNUSED_PARAM, char **argv)
264 kill(-1, SIGCONT); 265 kill(-1, SIGCONT);
265 return errors; 266 return errors;
266 } 267 }
268#endif
267 269
268#if ENABLE_KILL || ENABLE_KILLALL 270#if ENABLE_KILL || ENABLE_KILLALL
269 /* Pid or name is required for kill/killall */ 271 /* Pid or name is required for kill/killall */
diff --git a/shell/ash.c b/shell/ash.c
index fa71bd84d..88834f49a 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -3747,6 +3747,7 @@ static smallint doing_jobctl; //references:8
3747static void setjobctl(int); 3747static void setjobctl(int);
3748#endif 3748#endif
3749 3749
3750#if !ENABLE_PLATFORM_MINGW32
3750/* 3751/*
3751 * Ignore a signal. 3752 * Ignore a signal.
3752 */ 3753 */
@@ -3761,7 +3762,6 @@ ignoresig(int signo)
3761 sigmode[signo - 1] = S_HARD_IGN; 3762 sigmode[signo - 1] = S_HARD_IGN;
3762} 3763}
3763 3764
3764#if !ENABLE_PLATFORM_MINGW32
3765/* 3765/*
3766 * Only one usage site - in setsignal() 3766 * Only one usage site - in setsignal()
3767 */ 3767 */
@@ -3896,6 +3896,7 @@ setsignal(int signo)
3896} 3896}
3897#else 3897#else
3898#define setsignal(s) 3898#define setsignal(s)
3899#define ignoresig(s)
3899#endif 3900#endif
3900 3901
3901/* mode flags for set_curjob */ 3902/* mode flags for set_curjob */
@@ -4372,7 +4373,11 @@ sprint_status48(char *s, int status, int sigonly)
4372#endif 4373#endif
4373 st = WTERMSIG(status); 4374 st = WTERMSIG(status);
4374 if (sigonly) { 4375 if (sigonly) {
4376#ifdef SIGPIPE
4375 if (st == SIGINT || st == SIGPIPE) 4377 if (st == SIGINT || st == SIGPIPE)
4378#else
4379 if (st == SIGINT)
4380#endif
4376 goto out; 4381 goto out;
4377#if JOBS 4382#if JOBS
4378 if (WIFSTOPPED(status)) 4383 if (WIFSTOPPED(status))
@@ -10633,7 +10638,7 @@ evalcommand(union node *cmd, int flags)
10633 * we can just exec it. 10638 * we can just exec it.
10634 */ 10639 */
10635#if ENABLE_PLATFORM_MINGW32 10640#if ENABLE_PLATFORM_MINGW32
10636 if (!(flags & EV_EXIT) || trap[0]) { 10641 if (!(flags & EV_EXIT) || may_have_traps) {
10637 /* No, forking off a child is necessary */ 10642 /* No, forking off a child is necessary */
10638 struct forkshell fs; 10643 struct forkshell fs;
10639 10644
@@ -14394,6 +14399,7 @@ init(void)
14394 basepf.next_to_pgetc = basepf.buf = ckmalloc(IBUFSIZ); 14399 basepf.next_to_pgetc = basepf.buf = ckmalloc(IBUFSIZ);
14395 basepf.linno = 1; 14400 basepf.linno = 1;
14396 14401
14402#if !ENABLE_PLATFORM_MINGW32
14397 sigmode[SIGCHLD - 1] = S_DFL; /* ensure we install handler even if it is SIG_IGNed */ 14403 sigmode[SIGCHLD - 1] = S_DFL; /* ensure we install handler even if it is SIG_IGNed */
14398 setsignal(SIGCHLD); 14404 setsignal(SIGCHLD);
14399 14405
@@ -14401,6 +14407,7 @@ init(void)
14401 * Try: "trap '' HUP; bash; echo RET" and type "kill -HUP $$" 14407 * Try: "trap '' HUP; bash; echo RET" and type "kill -HUP $$"
14402 */ 14408 */
14403 signal(SIGHUP, SIG_DFL); 14409 signal(SIGHUP, SIG_DFL);
14410#endif
14404 14411
14405 { 14412 {
14406 char **envp; 14413 char **envp;
@@ -14838,7 +14845,7 @@ forkshell_openhere(struct forkshell *fs)
14838 ignoresig(SIGQUIT); //signal(SIGQUIT, SIG_IGN); 14845 ignoresig(SIGQUIT); //signal(SIGQUIT, SIG_IGN);
14839 ignoresig(SIGHUP); //signal(SIGHUP, SIG_IGN); 14846 ignoresig(SIGHUP); //signal(SIGHUP, SIG_IGN);
14840 ignoresig(SIGTSTP); //signal(SIGTSTP, SIG_IGN); 14847 ignoresig(SIGTSTP); //signal(SIGTSTP, SIG_IGN);
14841 signal(SIGPIPE, SIG_DFL); 14848 //signal(SIGPIPE, SIG_DFL);
14842 if (redir->type == NHERE) { 14849 if (redir->type == NHERE) {
14843 size_t len = strlen(redir->nhere.doc->narg.text); 14850 size_t len = strlen(redir->nhere.doc->narg.text);
14844 full_write(pip[1], redir->nhere.doc->narg.text, len); 14851 full_write(pip[1], redir->nhere.doc->narg.text, len);