Closed dspinellis closed 7 years ago
Consider the following example, which freezes, because cat never negotiates.
cat
$ dgsh -c 'echo hi | cat -n' getopt: invalid option -- 'n' Usage: cat [-u] [file ...]
Here is a sketch of the proposed solution.
dgsh_negotiate
negotiation_completed
true
#include <stdbool.h> #include <stdlib.h>
bool negotiation_completed = false; static void on_exit_handler(int v, void *ptr) { if (negotiation_completed) return; // Run negotiation indicating a failure }
static attribute((constructor)) install_on_exit_handler(void) { on_exit(dgsh_on_exit_handler); }
Consider the following example, which freezes, because
cat
never negotiates.Here is a sketch of the proposed solution.
dgsh_negotiate
to setnegotiation_completed
totrue
bool negotiation_completed = false; static void on_exit_handler(int v, void *ptr) { if (negotiation_completed) return; // Run negotiation indicating a failure }
static attribute((constructor)) install_on_exit_handler(void) { on_exit(dgsh_on_exit_handler); }