46 #include <sys/types.h>
52 #define OOREXX_PIDFILE "/tmp/ooRexx.pid"
67 void Run (
bool asService)
105 int main(
int argc,
char *argv[])
114 printf(
"Error: Invalid command line option(s).\n");
115 printf(
" Aborting execution.\n\n");
121 len = read(pfile, pid_buf,
sizeof(pid_buf) - 1);
124 pid = (pid_t)atoi(pid_buf);
125 if (pid && (pid == getpid() || kill(pid, 0) < 0)) {
129 printf(
"Error: There is already a server running.\n");
130 printf(
" Aborting execution.\n");
137 S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH);
141 printf(
" Aborting execution.\n\n");
144 snprintf(pid_buf,
sizeof(pid_buf),
"%d\n", (
int)getpid());
145 write(pfile, pid_buf, strlen(pid_buf));
149 (void) sigemptyset(&sa.sa_mask);
150 (void) sigaddset(&sa.sa_mask, SIGTERM);
151 sa.sa_flags = SA_RESTART;
152 sa.sa_handler =
Stop;
153 if (sigaction(SIGTERM, &sa, NULL) == -1) {
void listenForConnections()
int main(int argc, char *argv[])