From: Jens Axboe Date: Thu, 25 Sep 2014 21:17:06 +0000 (-0600) Subject: iowatcher: wrap system() in a checker function X-Git-Tag: blktrace-1.2.0~27 X-Git-Url: https://git.kernel.dk/?p=blktrace.git;a=commitdiff_plain;h=2cf87e6092da7b36d5ef10c830ddf12d9e18121d iowatcher: wrap system() in a checker function Kills the errors on unchecked return of system() Signed-off-by: Jens Axboe --- 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)