Skip to content
Snippets Groups Projects
Commit a90920e3 authored by Nils Schneider's avatar Nils Schneider
Browse files

gluon-announced: avoid spawning zombies

parent 40321595
No related branches found
No related tags found
No related merge requests found
...@@ -51,9 +51,6 @@ void usage() { ...@@ -51,9 +51,6 @@ void usage() {
char *run_script(size_t *length, const char *script) { char *run_script(size_t *length, const char *script) {
FILE *f; FILE *f;
f = popen(script, "r");
char *buffer; char *buffer;
buffer = calloc(BUFFER, sizeof(char)); buffer = calloc(BUFFER, sizeof(char));
...@@ -63,6 +60,7 @@ char *run_script(size_t *length, const char *script) { ...@@ -63,6 +60,7 @@ char *run_script(size_t *length, const char *script) {
return NULL; return NULL;
} }
f = popen(script, "r");
size_t read_bytes = 0; size_t read_bytes = 0;
while (1) { while (1) {
...@@ -74,8 +72,10 @@ char *run_script(size_t *length, const char *script) { ...@@ -74,8 +72,10 @@ char *run_script(size_t *length, const char *script) {
read_bytes += ret; read_bytes += ret;
} }
if (fclose(f) != 0) int ret = pclose(f);
fprintf(stderr, "fclose on script failed\n");
if (ret != 0)
fprintf(stderr, "script exited with status %d\n", ret);
*length = read_bytes; *length = read_bytes;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment