diff options
author | Jens Axboe <axboe@fb.com> | 2014-09-25 15:17:06 -0600 |
---|---|---|
committer | Jens Axboe <axboe@fb.com> | 2014-09-25 15:17:06 -0600 |
commit | 2cf87e6092da7b36d5ef10c830ddf12d9e18121d (patch) | |
tree | 7d2a8924cf98fddf8136fcf268f060169c3fd5da | |
parent | 558a088d485c530027b369c77de5cd555b6b2cec (diff) | |
download | blktrace-2cf87e6092da7b36d5ef10c830ddf12d9e18121d.tar.gz |
iowatcher: wrap system() in a checker function
Kills the errors on unchecked return of system()
Signed-off-by: Jens Axboe <axboe@fb.com>
-rw-r--r-- | iowatcher/main.c | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/iowatcher/main.c b/iowatcher/main.c index cbf6c9a..2797afb 100644 --- a/iowatcher/main.c +++ b/iowatcher/main.c @@ -1016,12 +1016,22 @@ static void plot_queue_depth(struct plot *plot, unsigned int min_seconds, total_graphs_written++; } +static void system_check(const char *cmd) +{ + if (system(cmd) < 0) { + int err = errno; + + fprintf(stderr, "system exec failed (%d): %s\n", err, cmd); + exit(1); + } +} + static void convert_movie_files(char *movie_dir) { fprintf(stderr, "Converting svg files in %s\n", movie_dir); snprintf(line, line_len, "find %s -name \\*.svg | xargs -I{} -n 1 -P 8 rsvg-convert -o {}.png {}", movie_dir); - system(line); + system_check(line); } static void mencode_movie(char *movie_dir) @@ -1030,7 +1040,7 @@ static void mencode_movie(char *movie_dir) snprintf(line, line_len, "ffmpeg -r 20 -y -i %s/%%10d-%s.svg.png -b:v 250k " "-vcodec %s %s", movie_dir, output_filename, ffmpeg_codec, output_filename); - system(line); + system_check(line); } static void tencode_movie(char *movie_dir) @@ -1038,7 +1048,7 @@ static void tencode_movie(char *movie_dir) fprintf(stderr, "Creating movie %s with png2theora\n", movie_dir); snprintf(line, line_len, "png2theora -o %s %s/%%010d-%s.svg.png", output_filename, movie_dir, output_filename); - system(line); + system_check(line); } static void encode_movie(char *movie_dir) @@ -1060,10 +1070,10 @@ static void cleanup_movie(char *movie_dir) } fprintf(stderr, "Removing movie dir %s\n", movie_dir); snprintf(line, line_len, "rm %s/*", movie_dir); - system(line); + system_check(line); snprintf(line, line_len, "rmdir %s", movie_dir); - system(line); + system_check(line); } static void plot_io_movie(struct plot *plot) |