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 <calcurse@cryptocrack.de>
This commit is contained in:
Lukas Fleischer 2012-02-18 14:59:15 +01:00
parent fb58416f45
commit 9a8ea7ff91

View File

@ -1230,10 +1230,11 @@ io_log_display (struct io_file *log, char *msg, char *pager)
ans = fgetc (stdin); ans = fgetc (stdin);
if (ans == 'y') if (ans == 'y')
{ {
char cmd[BUFSIZ]; char *arg[] = { pager, log->name, NULL };
int pid;
snprintf (cmd, BUFSIZ, "%s %s", pager, log->name); if ((pid = fork_exec (NULL, NULL, pager, arg)))
system (cmd); child_wait (NULL, NULL, pid);
} }
} }
else else