aboutsummaryrefslogtreecommitdiff
path: root/libbb/vfork_daemon_rexec.c
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2017-05-29 14:20:10 +0100
committerRon Yorston <rmy@pobox.com>2017-05-29 14:34:28 +0100
commitda4f331955bed8afda670afcd58d524a04a0faa9 (patch)
treef6a3879aefdd714240f8c022375f687b512d2238 /libbb/vfork_daemon_rexec.c
parent74163a535fd21f5fcca4c052d2e7c192d3e264fa (diff)
parent6683d1cbb44859f549f87f882545b84b9369585c (diff)
downloadbusybox-w32-da4f331955bed8afda670afcd58d524a04a0faa9.tar.gz
busybox-w32-da4f331955bed8afda670afcd58d524a04a0faa9.tar.bz2
busybox-w32-da4f331955bed8afda670afcd58d524a04a0faa9.zip
Merge branch 'busybox' into merge
Diffstat (limited to 'libbb/vfork_daemon_rexec.c')
-rw-r--r--libbb/vfork_daemon_rexec.c28
1 files changed, 2 insertions, 26 deletions
diff --git a/libbb/vfork_daemon_rexec.c b/libbb/vfork_daemon_rexec.c
index a6d260a40..9ab49d0a1 100644
--- a/libbb/vfork_daemon_rexec.c
+++ b/libbb/vfork_daemon_rexec.c
@@ -123,28 +123,8 @@ int FAST_FUNC run_nofork_applet(int applet_no, char **argv)
123 123
124 /* In case getopt() or getopt32() was already called: 124 /* In case getopt() or getopt32() was already called:
125 * reset the libc getopt() function, which keeps internal state. 125 * reset the libc getopt() function, which keeps internal state.
126 *
127 * BSD-derived getopt() functions require that optind be set to 1 in
128 * order to reset getopt() state. This used to be generally accepted
129 * way of resetting getopt(). However, glibc's getopt()
130 * has additional getopt() state beyond optind, and requires that
131 * optind be set to zero to reset its state. So the unfortunate state of
132 * affairs is that BSD-derived versions of getopt() misbehave if
133 * optind is set to 0 in order to reset getopt(), and glibc's getopt()
134 * will core dump if optind is set 1 in order to reset getopt().
135 *
136 * More modern versions of BSD require that optreset be set to 1 in
137 * order to reset getopt(). Sigh. Standards, anyone?
138 */ 126 */
139#ifdef __GLIBC__ 127 GETOPT_RESET();
140 optind = 0;
141#else /* BSD style */
142 optind = 1;
143 /* optreset = 1; */
144#endif
145 /* optarg = NULL; opterr = 1; optopt = 63; - do we need this too? */
146 /* (values above are what they initialized to in glibc and uclibc) */
147 /* option_mask32 = 0; - not needed, no applet depends on it being 0 */
148 128
149 argc = 1; 129 argc = 1;
150 while (argv[argc]) 130 while (argv[argc])
@@ -169,11 +149,7 @@ int FAST_FUNC run_nofork_applet(int applet_no, char **argv)
169 restore_nofork_data(&old); 149 restore_nofork_data(&old);
170 150
171 /* Other globals can be simply reset to defaults */ 151 /* Other globals can be simply reset to defaults */
172#ifdef __GLIBC__ 152 GETOPT_RESET();
173 optind = 0;
174#else /* BSD style */
175 optind = 1;
176#endif
177 153
178 return rc & 0xff; /* don't confuse people with "exitcodes" >255 */ 154 return rc & 0xff; /* don't confuse people with "exitcodes" >255 */
179} 155}