Hello, this is my first attempt to add: - handler for SIGTERM - make rxapi capable of working with the AIX subsystem resource controller (SRC)
I had added some debugging output to the Stop() routine during my tests. The apiServer.terminateServer() gets called and then exit(1) gets called. So it can't be completely wrong :-)) Index: APIService.cpp / not checked with Linux ... I would need a volunteer for that :-) =================================================================== --- APIService.cpp (revision 4762) +++ APIService.cpp (working copy) @@ -87,6 +87,22 @@ apiServer.terminateServer(); // shut everything down } +/*==========================================================================* + * Function: Stop + * + * Purpose: + * + * handles the stop request. + * + * + *==========================================================================*/ +void Stop(int signo) +{ + apiServer.terminateServer(); // shut everything down + + exit(1); +} + ///////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////// // Routines to run RXAPI as an daemon BEGIN @@ -166,6 +182,10 @@ char pid_buf[256]; int pfile, len; pid_t pid = 0; +#if defined(AIX) + struct stat st; +#endif + struct sigaction sa; // Get the command line args if (argc > 1) { @@ -204,14 +224,62 @@ close(pfile); // make ourselves a daemon - if (morph2daemon() == false) { - return -1; + // - if this is AIX we check if the rxapi daemon was sarted via SRC + // - if the daemon was started via SRC we do not morph - the SRC handles this + // + // - add to AIX SRC without auto restart: + // mkssys -s rxapi -p /opt/ooRexx/bin/rxapi -i /dev/null -e /dev/console \ + // -o /dev/console -u 0 -S -n 15 -f 9 -O -Q + // + // - add to AIX SRC with auto restart: + // mkssys -s rxapi -p /opt/ooRexx/bin/rxapi -i /dev/null -e /dev/console \ + // -o /dev/console -u 0 -S -n 15 -f 9 -R -Q +#if defined(AIX) + if (fstat(0, &st) <0) { + if (morph2daemon() == false) { + return -1; + } + } else { + if ((st.st_mode & S_IFMT) == S_IFCHR) { + if (isatty(0)) { + if (morph2daemon() == false) { + return -1; + } + } + } else { + if (morph2daemon() == false) { + return -1; + } + } } +#else + if (morph2daemon() == false) { + return -1; + } +#endif // run the server +#if defined(AIX) if (run_as_daemon == false) { printf("Starting request processing loop.\n"); + } else { + (void) setsid(); } +#else + if (run_as_daemon == false) { + printf("Starting request processing loop.\n"); + } +#endif + + // handle kill -15 + (void) sigemptyset(&sa.sa_mask); + (void) sigaddset(&sa.sa_mask, SIGTERM); + sa.sa_flags = SA_RESTART; + sa.sa_handler = Stop; + if (sigaction(SIGTERM, &sa, NULL) == -1) { + exit(1); + } + Run(false); return 0; Bye Rainer Rick McGuire wrote: > I can't think of any reason why it would be a bad idea, though at this > point, it should only be developed on trunk for a future release and > not applied to the 4.0 branch. > > Rick > > On Thu, Jun 4, 2009 at 2:35 AM, Rainer Tammer <tam...@tammer.net> wrote: > >> Hello, >> if I did not miss something there is no explicit signal handler for >> SIGTERM in the API daemon. >> >> Sometimes a simple kill does not terminate the daemon. >> Would it be a problem if I add a signal handler for SIGTERM ? >> >> My idea is to add an handler which calls apiServer.terminateServer(); ... >> >> Is this a bad idea ? >> >> Bye >> Rainer >> >> > > ------------------------------------------------------------------------------ > OpenSolaris 2009.06 is a cutting edge operating system for enterprises > looking to deploy the next generation of Solaris that includes the latest > innovations from Sun and the OpenSource community. Download a copy and > enjoy capabilities such as Networking, Storage and Virtualization. > Go to: http://p.sf.net/sfu/opensolaris-get > _______________________________________________ > Oorexx-devel mailing list > Oorexx-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/oorexx-devel > > > ------------------------------------------------------------------------------ OpenSolaris 2009.06 is a cutting edge operating system for enterprises looking to deploy the next generation of Solaris that includes the latest innovations from Sun and the OpenSource community. Download a copy and enjoy capabilities such as Networking, Storage and Virtualization. Go to: http://p.sf.net/sfu/opensolaris-get _______________________________________________ Oorexx-devel mailing list Oorexx-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/oorexx-devel