aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2017-08-30 16:57:45 +0100
committerRon Yorston <rmy@pobox.com>2017-08-30 17:09:57 +0100
commit0599746d9bcf513c4898cbd1a46ef1d5b3478627 (patch)
treee9e64f90efef836b22b404bbe351032cd14a8050
parent002f3c9ea19a1cd68294d905f566be5b615a9bef (diff)
downloadbusybox-w32-0599746d9bcf513c4898cbd1a46ef1d5b3478627.tar.gz
busybox-w32-0599746d9bcf513c4898cbd1a46ef1d5b3478627.tar.bz2
busybox-w32-0599746d9bcf513c4898cbd1a46ef1d5b3478627.zip
win32: make vfork fail at compile-time
Nothing in busybox-w32 uses fork. Remove the implementations of fork, vfork and xvfork so that, for example, enabling cpio pass-through causes an error at compile-time, not run-time. MinGW-w64 defines pid_t, so we don't have to. Ensure code containing xvfork in netcat is disabled when NC_EXTRA is disabled. Otherwise removing the implementation of vfork costs 64 bytes.
-rw-r--r--include/libbb.h4
-rw-r--r--include/mingw.h8
-rw-r--r--networking/nc.c4
3 files changed, 8 insertions, 8 deletions
diff --git a/include/libbb.h b/include/libbb.h
index 2b349ed12..9ce89636a 100644
--- a/include/libbb.h
+++ b/include/libbb.h
@@ -1103,6 +1103,7 @@ void exec_prog_or_SHELL(char **argv) NORETURN FAST_FUNC;
1103 1103
1104/* xvfork() can't be a _function_, return after vfork in child mangles stack 1104/* xvfork() can't be a _function_, return after vfork in child mangles stack
1105 * in the parent. It must be a macro. */ 1105 * in the parent. It must be a macro. */
1106#if !ENABLE_PLATFORM_MINGW32
1106#define xvfork() \ 1107#define xvfork() \
1107({ \ 1108({ \
1108 pid_t bb__xvfork_pid = vfork(); \ 1109 pid_t bb__xvfork_pid = vfork(); \
@@ -1110,6 +1111,9 @@ void exec_prog_or_SHELL(char **argv) NORETURN FAST_FUNC;
1110 bb_perror_msg_and_die("vfork"); \ 1111 bb_perror_msg_and_die("vfork"); \
1111 bb__xvfork_pid; \ 1112 bb__xvfork_pid; \
1112}) 1113})
1114#else
1115#define xvfork() vfork()
1116#endif
1113#if BB_MMU 1117#if BB_MMU
1114pid_t xfork(void) FAST_FUNC; 1118pid_t xfork(void) FAST_FUNC;
1115#endif 1119#endif
diff --git a/include/mingw.h b/include/mingw.h
index ff5e8ee1e..d7dabacaf 100644
--- a/include/mingw.h
+++ b/include/mingw.h
@@ -7,11 +7,6 @@
7 */ 7 */
8typedef int gid_t; 8typedef int gid_t;
9typedef int uid_t; 9typedef int uid_t;
10#ifndef _WIN64
11typedef int pid_t;
12#else
13typedef __int64 pid_t;
14#endif
15 10
16#define DEFAULT_UID 1000 11#define DEFAULT_UID 1000
17#define DEFAULT_GID 1000 12#define DEFAULT_GID 1000
@@ -397,7 +392,6 @@ NOIMPL(getsid,pid_t pid UNUSED_PARAM);
397IMPL(getuid,int,DEFAULT_UID,void); 392IMPL(getuid,int,DEFAULT_UID,void);
398int getlogin_r(char *buf, size_t len); 393int getlogin_r(char *buf, size_t len);
399int fcntl(int fd, int cmd, ...); 394int fcntl(int fd, int cmd, ...);
400#define fork() -1
401IMPL(fsync,int,0,int fd UNUSED_PARAM); 395IMPL(fsync,int,0,int fd UNUSED_PARAM);
402int kill(pid_t pid, int sig); 396int kill(pid_t pid, int sig);
403int link(const char *oldpath, const char *newpath); 397int link(const char *oldpath, const char *newpath);
@@ -417,7 +411,7 @@ long sysconf(int name);
417IMPL(getpagesize,int,4096,void); 411IMPL(getpagesize,int,4096,void);
418NOIMPL(ttyname_r,int fd UNUSED_PARAM, char *buf UNUSED_PARAM, int sz UNUSED_PARAM); 412NOIMPL(ttyname_r,int fd UNUSED_PARAM, char *buf UNUSED_PARAM, int sz UNUSED_PARAM);
419int mingw_unlink(const char *pathname); 413int mingw_unlink(const char *pathname);
420NOIMPL(vfork,void); 414pid_t vfork(void);
421int mingw_access(const char *name, int mode); 415int mingw_access(const char *name, int mode);
422int mingw_rmdir(const char *name); 416int mingw_rmdir(const char *name);
423int mingw_isatty(int fd); 417int mingw_isatty(int fd);
diff --git a/networking/nc.c b/networking/nc.c
index df073d7df..3437c565e 100644
--- a/networking/nc.c
+++ b/networking/nc.c
@@ -198,7 +198,7 @@ int nc_main(int argc, char **argv)
198 } 198 }
199#endif 199#endif
200 close_on_exec_on(sfd); 200 close_on_exec_on(sfd);
201 accept_again: 201 IF_NC_EXTRA(accept_again:)
202 cfd = accept(sfd, NULL, 0); 202 cfd = accept(sfd, NULL, 0);
203 if (cfd < 0) 203 if (cfd < 0)
204 bb_perror_msg_and_die("accept"); 204 bb_perror_msg_and_die("accept");
@@ -216,6 +216,7 @@ int nc_main(int argc, char **argv)
216 /*signal(SIGALRM, SIG_DFL);*/ 216 /*signal(SIGALRM, SIG_DFL);*/
217 } 217 }
218 218
219#if ENABLE_NC_EXTRA
219 /* -e given? */ 220 /* -e given? */
220 if (execparam) { 221 if (execparam) {
221 pid_t pid; 222 pid_t pid;
@@ -234,6 +235,7 @@ int nc_main(int argc, char **argv)
234 IF_NC_EXTRA(BB_EXECVP(execparam[0], execparam);) 235 IF_NC_EXTRA(BB_EXECVP(execparam[0], execparam);)
235 IF_NC_EXTRA(bb_perror_msg_and_die("can't execute '%s'", execparam[0]);) 236 IF_NC_EXTRA(bb_perror_msg_and_die("can't execute '%s'", execparam[0]);)
236 } 237 }
238#endif
237 239
238 /* Select loop copying stdin to cfd, and cfd to stdout */ 240 /* Select loop copying stdin to cfd, and cfd to stdout */
239 241