--- smsdaemon/Util.cpp 2008/12/18 06:53:29 196 +++ smsdaemon/Util.cpp 2008/12/19 07:03:34 203 @@ -10,6 +10,9 @@ #include #include #include +#include +#include +#include #include #include @@ -420,6 +423,47 @@ return (pclose(p)); } + int my_system2 (const char *command) + { + int pid, status; + + if (command == 0) + return 1; + // printf("forking ...\n"); + pid = fork(); + if (pid == -1) + return -1; + if (pid == 0) + { + char *argv[4]; + argv[0] = (char*) "sh"; + argv[1] = (char*) "-c"; + argv[2] = (char *) command; + argv[3] = 0; + // printf("chaining ...\n"); + execve("/bin/sh", argv, environ); + // printf("Chaining failed!\n"); + exit(127); + } + do + { + // printf("Waiting on PID: %d\n",pid); + if (waitpid(pid, &status, 0) == -1) + { + // printf("erc: %d\n",errno); + if (errno != EINTR) + return -1; + } + else + { + // printf("status: %d\n",status); + return status; + } + } + while (1); + } + + string readfile(string filename) { string str;