]> git.itanic.dy.fi Git - rrdd/commitdiff
process: Make run() execute synchronously
authorTimo Kokkonen <timo.t.kokkonen@iki.fi>
Sat, 9 Jul 2016 06:50:07 +0000 (09:50 +0300)
committerTimo Kokkonen <timo.t.kokkonen@iki.fi>
Sat, 9 Jul 2016 06:55:00 +0000 (09:55 +0300)
Currently there are no need for running the process asynchronously on
background, so we might just make it run synchronously instead. This
simplifies the calling convention and also removes completely the need
to fork and possibly race in glibc functions.

Signed-off-by: Timo Kokkonen <timo.t.kokkonen@iki.fi>
process.c
rrdtool.c

index 8d3d18fdd94de8776b5ee7e8882b7159c98a84e2..b4319fe869aa92188c90762e987670c8362419ba 100644 (file)
--- a/process.c
+++ b/process.c
@@ -751,9 +751,6 @@ int run(const char *cmd, char *const argv[])
        int maxfd;
        int eof = 0;
 
-       if ((child = do_fork()))
-           return child;
-
        child = run_piped(cmd, argv, NULL, &ofd, &efd);
 
        FD_ZERO(&rfds);
@@ -828,7 +825,6 @@ print:
 
        harvest_zombies(child);
 
-       exit(1);
        return 0;
 }
 
index 58c0f57b069cfcadcc3728f76f4330f836b4e71d..be6232177f909d8217e1f0fef8509b764f80b68b 100644 (file)
--- a/rrdtool.c
+++ b/rrdtool.c
@@ -91,8 +91,7 @@ int rrdtool_draw_image(struct rrd_image *image)
 
        add_arg(args, argcnt, argstr, idx, "COMMENT: %s\\c", timestamp);
 
-       pid = run(cmd, args);
-       harvest_zombies(pid);
+       run(cmd, args);
 
        rename(tmpfile, image->image_filename);
 
@@ -278,13 +277,11 @@ static int do_rrdtool_update_data(struct rrd_database *rrd)
                sanitize_rrd_update_data(data + l);
                write_to_logfile(rrd, data);
 
-               pid = run(cmd, cmdline);
-               harvest_zombies(pid);
+               run(cmd, cmdline);
        }
 
        if (rrd->pre_draw_cmd && !strcmp(rrd->pre_draw_cmd[0], "shell")) {
-               pid = run(rrd->pre_draw_cmd[1], &rrd->pre_draw_cmd[1]);
-               harvest_zombies(pid);
+               run(rrd->pre_draw_cmd[1], &rrd->pre_draw_cmd[1]);
        }
 
        if (rrd->images)
@@ -362,7 +359,7 @@ static int create_database(struct rrd_database *db)
 //     char cmd[] = "echo";
        char *args[512], argstr[ARGSTR_LEN];
        int idx = 0, argcnt = 0;
-       int child, i;
+       int i;
 
        if (!db->filename) {
                pr_err("Database %s missing database filename\n", db->name);
@@ -398,9 +395,7 @@ static int create_database(struct rrd_database *db)
                        db->archives[i].rows);
        }
 
-       child = run(cmd, args);
-
-       harvest_zombies(child);
+       run(cmd, args);
 
        return 0;
 }