aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2019-01-22 12:52:55 -0800
committerRob Landley <rob@landley.net>2019-01-22 18:31:24 -0600
commitbbadc5e14136a4a2011080c08e064108d71e1429 (patch)
treed2b279d4c1ab3cc797764370c2ca3f058bd9b675
parent208163ac89cfc14db46cd089110517761b69dc76 (diff)
downloadtoybox-bbadc5e14136a4a2011080c08e064108d71e1429.tar.gz
Fix sigjmp_buf/jmp_buf mismatches.
Broke the bionic build: external/toybox/toys/net/netcat.c:188:37: error: incompatible pointer types assigning to 'sigjmp_buf *' (aka 'long (*)[33]') from 'jmp_buf *' (aka 'long (*)[32]') [-Werror,-Wincompatible-pointer-types] if (toys.optflags&FLAG_L) NOEXIT(child = XVFORK()); ^~~~~~~~~~~~~~~~~~~~~~~~ external/toybox/lib/lib.h:375:19: note: expanded from macro 'NOEXIT' #define NOEXIT(x) WOULD_EXIT(_noexit_res, x) ^~~~~~~~~~~~~~~~~~~~~~~~~~ external/toybox/lib/lib.h:367:16: note: expanded from macro 'WOULD_EXIT' toys.rebound = &_noexit; \ ^ ~~~~~~~~ 1 error generated.
-rw-r--r--lib/lib.h6
-rw-r--r--toys.h2
-rw-r--r--toys/pending/sh.c4
-rw-r--r--www/code.html2
4 files changed, 7 insertions, 7 deletions
diff --git a/lib/lib.h b/lib/lib.h
index 546b32b3..ed31ffa9 100644
--- a/lib/lib.h
+++ b/lib/lib.h
@@ -360,12 +360,12 @@ void names_to_pid(char **names, int (*callback)(pid_t pid, char *name));
pid_t __attribute__((returns_twice)) xvforkwrap(pid_t pid);
#define XVFORK() xvforkwrap(vfork())
-// Wrapper to make xfuncs() return (via longjmp) instead of exiting.
+// Wrapper to make xfuncs() return (via siglongjmp) instead of exiting.
// Assigns true/false "did it exit" value to first argument.
-#define WOULD_EXIT(y, x) do { jmp_buf _noexit; \
+#define WOULD_EXIT(y, x) do { sigjmp_buf _noexit; \
int _noexit_res; \
toys.rebound = &_noexit; \
- _noexit_res = setjmp(_noexit); \
+ _noexit_res = sigsetjmp(_noexit, 1); \
if (!_noexit_res) do {x;} while(0); \
toys.rebound = 0; \
y = _noexit_res; \
diff --git a/toys.h b/toys.h
index df37b55e..9e49900b 100644
--- a/toys.h
+++ b/toys.h
@@ -108,7 +108,7 @@ extern struct toy_context {
char wasroot; // dropped setuid
// This is at the end so toy_init() doesn't zero it.
- sigjmp_buf *rebound; // longjmp here instead of exit when do_rebound set
+ sigjmp_buf *rebound; // siglongjmp here instead of exit when do_rebound
struct arg_list *xexit; // atexit() functions for xexit(), set by sigatexit()
void *stacktop; // nested toy_exec() call count, or 0 if vforked
} toys;
diff --git a/toys/pending/sh.c b/toys/pending/sh.c
index 0bfd32c5..8a9e93b6 100644
--- a/toys/pending/sh.c
+++ b/toys/pending/sh.c
@@ -205,13 +205,13 @@ static void run_pipeline(struct pipeline *line)
// Is this command a builtin that should run in this process?
if (tl && (tl->flags & TOYFLAG_NOFORK)) {
struct toy_context temp;
- jmp_buf rebound;
+ sigjmp_buf rebound;
// This fakes lots of what toybox_main() does.
memcpy(&temp, &toys, sizeof(struct toy_context));
memset(&toys, 0, sizeof(struct toy_context));
- if (!setjmp(rebound)) {
+ if (!sigsetjmp(rebound, 1)) {
toys.rebound = &rebound;
toy_init(tl, cmd->argv);
tl->toy_main();
diff --git a/www/code.html b/www/code.html
index b1b17ef5..953c53bb 100644
--- a/www/code.html
+++ b/www/code.html
@@ -653,7 +653,7 @@ and change the exit code to indicate error, lets our toys.exit function
change happen for signal exit paths and lets us remove the functions
after we've called them.</p>
-<p>You can intercept our exit by assigning a setjmp/longjmp buffer to
+<p>You can intercept our exit by assigning a sigsetjmp/siglongjmp buffer to
toys.rebound (set it back to zero to restore the default behavior).
If you do this, cleaning up resource leaks is your problem.</p>