gluon-announced: avoid spawning zombies

This commit is contained in:
Nils Schneider 2014-08-25 21:53:21 +02:00
parent 955cc686db
commit 8a71c02ce6
1 changed files with 5 additions and 5 deletions

View File

@ -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) {
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) {
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;