dspinellis / dgsh

Shell supporting pipelines to and from multiple processes
http://www.spinellis.gr/sw/dgsh/
Other
323 stars 23 forks source link

Gracefully teminate negotiation when an error occurs #39

Closed dspinellis closed 7 years ago

dspinellis commented 7 years ago

Consider the following example, which freezes, because cat never negotiates.

$ dgsh -c 'echo hi | cat -n'
getopt: invalid option -- 'n'
Usage: cat [-u] [file ...]

Here is a sketch of the proposed solution.

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); }