From 9a8ea7ff91486b53511d49a1b1bb44d48a549018 Mon Sep 17 00:00:00 2001 From: Lukas Fleischer Date: Sat, 18 Feb 2012 14:59:15 +0100 Subject: src/io.c: Use fork_exec() instead of system() Speeds up execution, prevents failures when pager or log file contains spaces, fixes a warning seen with "-Wunused-result". Signed-off-by: Lukas Fleischer --- src/io.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/io.c b/src/io.c index 1aa431b..6c981d4 100644 --- a/src/io.c +++ b/src/io.c @@ -1230,10 +1230,11 @@ io_log_display (struct io_file *log, char *msg, char *pager) ans = fgetc (stdin); if (ans == 'y') { - char cmd[BUFSIZ]; + char *arg[] = { pager, log->name, NULL }; + int pid; - snprintf (cmd, BUFSIZ, "%s %s", pager, log->name); - system (cmd); + if ((pid = fork_exec (NULL, NULL, pager, arg))) + child_wait (NULL, NULL, pid); } } else -- cgit v1.2.3-70-g09d2