Tehre is probably a better way to do this.
Gbp-Pq: Name 0007-output-Replace-system-with-explicit-bash-invocation.patch
#include <assert.h>
#include <fcntl.h>
#include <unistd.h>
+#include <sys/wait.h>
#include <nbdkit-filter.h>
CLEANUP_FREE char *str = NULL;
size_t len = 0;
int r;
+ int pid;
+ int wstatus = 0;
/* Create the shell variables + script. */
fp = open_memstream (&str, &len);
fclose (fp);
/* Run the script. Log the status, but ignore it. */
- r = system (str);
+ if (pid = fork() == 0) {
+ execl ("/bin/bash", "sh", "-c", str, NULL);
+ exit (-errno);
+ } else if (pid > 0) {
+ waitpid (pid, &r, 0);
+ } else {
+ r = -1;
+ }
exit_status_to_nbd_error (r, "logscript");
}