don't use WNOHANG in waitpid; check child status to see if the formatter exited normally or abended & return the original code fragment if the latter

This commit is contained in:
david parsons
2022-08-02 09:34:31 -07:00
parent 5b6e5b0e07
commit 97784f4ca5
+5 -2
View File
@@ -141,11 +141,14 @@ external_codefmt(char *src, int len, char *lang)
res = realloc(res, bufsize += 1000);
}
res[curr] = 0;
waitpid(child, &child_status, WNOHANG);
waitpid(child, &child_status, 0);
close(toparent[RECEIVER]);
return res;
if ( WIFEXITED(child_status) )
return res;
else
free(res); /* something failed; just return the original string */
}
else if ( child == 0 ) {
close(tochild[SENDER]);