46 #include <sys/types.h>
60 #define OOREXX_PIDFILE "/tmp/ooRexx.pid"
63 #define OOREXX_PIDFILE "/tmp/ooRexx.pid"
80 void Run (
bool asService)
132 if (signal(SIGPIPE, SIG_IGN) == SIG_ERR) {
160 snprintf(pid_buf,
sizeof(pid_buf),
"%d\n", (
int)getpid());
161 ssize_t writeResult = write(pfile, pid_buf, strlen(pid_buf));
165 int chdirResult = chdir(
"/");
167 for(
int i = 0; i < 1024; i++) {
183 int main(
int argc,
char *argv[])
191 printf(
"Error: Invalid command line option(s).\n");
192 printf(
" Aborting execution.\n\n");
198 len = read(pfile, pid_buf,
sizeof(pid_buf) - 1);
201 pid = (pid_t)atoi(pid_buf);
202 if (pid && (pid == getpid() || kill(pid, 0) < 0)) {
206 printf(
"Error: There is already a server running.\n");
207 printf(
" Aborting execution.\n");
214 S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH);
218 printf(
" Aborting execution.\n\n");
221 snprintf(pid_buf,
sizeof(pid_buf),
"%d\n", (
int)getpid());
222 ssize_t r = write(pfile, pid_buf, strlen(pid_buf));
242 printf(
"Starting request processing loop.\n");
246 (void) sigemptyset(&sa.sa_mask);
247 (void) sigaddset(&sa.sa_mask, SIGTERM);
248 sa.sa_flags = SA_RESTART;
249 sa.sa_handler =
Stop;
250 if (sigaction(SIGTERM, &sa, NULL) == -1) {
void listenForConnections()
static bool morph2daemon(void)
int main(int argc, char *argv[])