head 1.1; access; symbols pkgsrc-2026Q1:1.1.0.10 pkgsrc-2026Q1-base:1.1 pkgsrc-2025Q4:1.1.0.8 pkgsrc-2025Q4-base:1.1 pkgsrc-2025Q3:1.1.0.6 pkgsrc-2025Q3-base:1.1 pkgsrc-2025Q2:1.1.0.4 pkgsrc-2025Q2-base:1.1 pkgsrc-2025Q1:1.1.0.2 pkgsrc-2025Q1-base:1.1; locks; strict; comment @// @; 1.1 date 2025.01.17.17.44.22; author rhialto; state Exp; branches; next ; commitid iHCA78dbjRjoDRFF; desc @@ 1.1 log @lang/oorexx: stop rxapi server which is started during the build. This adds some patches so that the rxapi command gets an argument to tell it to stop a currently running rxapi server. Reported upstream as https://mastodon.social/@@dec_hl/113843692204297339 @ text @$NetBSD$ A combination of changes to make it possible to terminate the rxapi process which is auto-started: - use the lock file as a pid-file, - add a command line argument "stop" that sends SIGTERM to the pid from the pidfile, - let the signal handler continue running so that cleanup code can run. https://sourceforge.net/p/oorexx/bugs/1993/ --- rexxapi/server/platform/unix/APIService.cpp.orig 2023-04-19 14:25:29.000000000 +0000 +++ rexxapi/server/platform/unix/APIService.cpp @@@@ -64,7 +64,8 @@@@ void Stop(int signo) { apiServer.terminateServer(); // shut everything down - exit(1); + /* Do not exit here, but let the main loop finish and the epilog code clean + * up the lock file. */ } @@@@ -118,9 +119,15 @@@@ void releaseLock (const char *lockFileNa */ int main(int argc, char *argv[]) { + int stopflag = 0; + if (argc > 1) { - printf("rxapi: no args allowed\n"); + if (strcmp(argv[1], "stop") == 0) { + stopflag = 1; + } else { + printf("rxapi: no args allowed\n"); + } } // a buffer for generating the name @@@@ -138,10 +145,30 @@@@ int main(int argc, char *argv[]) int fd; if ((fd = acquireLock(lockFileName)) == -1) { + if (stopflag) { + FILE *f = fopen(lockFileName, "r"); + long pid = 0; + + if (f && fscanf(f, "%ld", &pid) == 1 && (pid_t)pid > 1 && + kill((pid_t)pid, SIGTERM) == 0) { + exit(0); + } + exit(1); + } printf("rxapi: lockfile is locked by another rxapi instance; exiting\n"); return EACCES; } + if (stopflag) { + printf("rxapi: no server is running.\n"); + releaseLock(lockFileName, fd); // release the exclusive lock + exit(1); + } printf("rxapi: lockfile lock acquired\n"); + { + char pidstring[32]; + sprintf(pidstring, "%ld\n", (long)getpid()); + write(fd, pidstring, strlen(pidstring)); + } struct sigaction sa; @