summaryrefslogtreecommitdiffstats
path: root/src/exec.c
diff options
context:
space:
mode:
authorIku <iku@yokattana.com>2017-02-09 15:01:04 +0100
committerIku <iku@yokattana.com>2017-02-09 15:05:14 +0100
commite57b88032ffe4733024e8e29442652393531b6b0 (patch)
treed78f407c23ac1fed93b31869a18c36384d0888ef /src/exec.c
parent895334d111060e805fbbe60b9020f6c32f3b90c5 (diff)
Use sc_error and app_exit instead of perror/exit
Diffstat (limited to 'src/exec.c')
-rw-r--r--src/exec.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/exec.c b/src/exec.c
index 72fe3dc..fe92a3e 100644
--- a/src/exec.c
+++ b/src/exec.c
@@ -4,6 +4,7 @@
#include <unistd.h>
#include <string.h>
#include <sys/wait.h> // for wait
+#include <errno.h>
#include "macros.h"
#include "conf.h"
@@ -11,6 +12,7 @@
#include "utils/string.h"
#include "screen.h"
#include "sc.h"
+#include "main.h" // exit_app
int exec_cmd (char * line) {
int waitres;
@@ -54,8 +56,8 @@ int exec_cmd (char * line) {
execvp(argv[0], argv);
free(argv);
- printf("Error executing command. ");
- exit(-1);
+ sc_error("Error executing command. ");
+ exit_app(-1);
} else { // we are in parent process
close(my_pipe[1]); // parent doesn't write
@@ -63,17 +65,16 @@ int exec_cmd (char * line) {
while (read(my_pipe[0], reading_buf, 1) > 0) {
if (!write(1, reading_buf, 1)) {
- perror(NULL);
- exit(-1);
+ sc_error("Failed to read command output: %s", strerror(errno));
+ exit_app(-1);
}
}
close(my_pipe[0]);
wait(&waitres);
if (system("echo -n 'Press ENTER to return.'") == -1) {
- /* system() call itself failed */
- perror(NULL);
- exit(-1);
+ sc_error("Failed to show ENTER prompt: %s", strerror(errno));
+ exit_app(-1);
}
getchar();