The patch set seem to be in a good shape and pretty stable for quite a while.
Could you add one more minor improvement, a new line after variables declaration?
+ int exit_code = wait_result_to_exit_code(result);
+ char buf[32];
...here
+ snprintf(buf, sizeof(buf), "%d", exit_code);
+ SetVariable(pset.vars, "SHELL_EXIT_CODE", buf);
+ SetVariable(pset.vars, "SHELL_ERROR", "true");
+ char exit_code_buf[32];
... and here
+ snprintf(exit_code_buf, sizeof(exit_code_buf), "%d",
+ wait_result_to_exit_code(exit_code));
+ SetVariable(pset.vars, "SHELL_EXIT_CODE", exit_code_buf);
+ SetVariable(pset.vars, "SHELL_ERROR", "true");