From 5a8218b13fbe21e4c85a484933ca201b666323ee Mon Sep 17 00:00:00 2001 From: Joursoir Date: Wed, 21 Oct 2020 19:26:03 +0000 Subject: fix bug: work outside working dir; refactor --- handerror.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'handerror.c') diff --git a/handerror.c b/handerror.c index 753e834..35e8f28 100644 --- a/handerror.c +++ b/handerror.c @@ -1,5 +1,7 @@ #include #include +#include +#include void callError(int num) { @@ -13,3 +15,16 @@ void printError(char *text) exit(4); } +void easyFork(char *name, char *arguments[]) +{ + int pid; + pid = fork(); + if(pid == -1) callError(100); + if(pid == 0) { /* new process */ + execvp(name, arguments); + perror(name); + exit(4); + } + wait(&pid); +} + -- cgit v1.2.3-18-g5258