diff options
author | Rob Landley <rob@landley.net> | 2015-11-08 16:47:52 -0600 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2015-11-08 16:47:52 -0600 |
commit | 2f69ee2f0f25c6fc1dbc440c14c52aeaaf35b6a8 (patch) | |
tree | 6777cc094f5030271c785d23493e3a05bab43314 | |
parent | 6fd77eab77ba51579eaece4d3e12b5b890638124 (diff) | |
download | toybox-2f69ee2f0f25c6fc1dbc440c14c52aeaaf35b6a8.tar.gz |
NOEXIT(thingy()) wrapper to turn xwrap() functions into warning versions.
Also WOULD_EXIT(x, thingy()) to set a variable to 1 or 0 showing whether or
not thingy() tried to exit. I'd love to be able to do "x = NOEXIT(thingy());"
but haven't figured out a syntax to make that work yet...
-rw-r--r-- | lib/lib.h | 11 |
1 files changed, 11 insertions, 0 deletions
@@ -256,5 +256,16 @@ void names_to_pid(char **names, int (*callback)(pid_t pid, char *name)); pid_t xvforkwrap(pid_t pid); #define XVFORK() xvforkwrap(vfork()) +#define WOULD_EXIT(y, x) { jmp_buf _noexit; \ + int _noexit_res; \ + toys.rebound = &_noexit; \ + _noexit_res = setjmp(_noexit); \ + if (!_noexit_res) do {x;} while(0); \ + toys.rebound = 0; \ + y = _noexit_res; \ +} + +#define NOEXIT(x) WOULD_EXIT(_noexit_res, x) + // Functions in need of further review/cleanup #include "lib/pending.h" |