kranenbu%HLERUL5I.BITNET@cunyvm.cuny.edu (05/12/89)
As mentioned in SunSpots v7n194, the selection_svc program hangs around after exitting suntools. Since I started some experiments with customised suntools executables this has become a major nuiscance, since installing a new /usr/bin/suntools (late at night) invariably leads to swapping errors (the next morning, in client selection_svc's which I forgot to kill). The following hack seems to get rid of selection_svc as soon as one quits suntools (please note that this is based on the SunOS3.5 version): In `suntools.c' declare a variable ! static int selection_svc_pid = 0; somewhere, then look for the code where suntools prepares for exit. In SunOS3.5, this is the context: > * Destroy screen sends SIGTERMs to all existing windows and > * wouldn''t let any windows install themselves in the window tree. > * Calling process of win_screedestroy is spared SIGTERM. > */ > (void)win_screendestroy(rootfd); > (void)close(placeholderfd); Add a line ! if (selection_svc_pid) kill(selection_svc_pid, SIGTERM); Finally, make the routine `root_start_service()' (right at the end of suntools.c) look like this: static void root_start_service() { register int i; static char *args[2] = {"selection_svc", 0 }; if ((selection_svc_pid = vfork()) == 0) { for (i = 30; i > 2; i--) { (void)close(i); } execvp(seln_svc_file, args, 0); perror("Couldn't fork selection service"); sleep(7); exit(1); } #ifdef DEBUG fprintf(stderr, "Selection_pid is %d\n", selection_svc_pid); sleep(4); /* time to reflect on our hacks */ #endif } Next comes the tricky part. Merely killing the selection-service program apperently leaves the service registered at the portmapper, which causes delay and an error message when suntools is restarted. Somehow we must unregister this rpc-service. A look at `selection_svc.c' reveals that this program almost entirely consists of just a call to `seln_init_service()' (which I couldn't find documented in my copy of the chapter "The Selection Service & Library" of the SunView System Programmer's Guide). Anyway, browsing through the output of `nm /usr/lib/libsuntool.a', the eye was caught by a function named `seln_svc_stop()'. I decided to give it a try: (Here is the entire modified `selection_svc.c') __________ #ifndef lint static char sccsid[] = "@(#)selection_svc.c 1.3 87/01/07 Copyr 1985 Sun Micro"; #endif /* * Copyright (c) 1985 by Sun Microsystems, Inc. */ #include <sys/types.h> #include <stdio.h> #include <sys/signal.h> #include <sunwindow/notify.h> #ifdef STANDALONE #define EXIT(n) exit(n) #else #define EXIT(n) return(n) #endif extern void seln_init_service(), seln_svc_stop(); void signal_handler(sig) int sig; { if (sig != SIGTERM) fprintf(stderr, "Pollens!...\n"); #ifdef DEBUG fprintf(stderr, "Selection_svc: got SIGTERM...\n"); #endif seln_svc_stop(); exit(0); } #ifdef STANDALONE main(argc, argv) #else selection_svc_main(argc, argv) #endif int argc; char **argv; { int debug = 0; if (argc > 1 && argv[1][0] == '-' && argv[1][1] == 'd') debug = 1; signal(SIGTERM, signal_handler); seln_init_service(debug); (void)notify_start(); #ifdef DEBUG fprintf(stderr, "Selection_svc exitting\n"); #endif EXIT(0); } --------------- I don't know whether `seln_svc_stop()' actually takes parameters or not (should the `debug' variable be passed again?). I also don't know what the call to `notify_start()' is meant for. Comments are appreciated. So far, things seem to work: if selection_svc is sent a SIGTERM signal, a message "selection-services stopped normally" appears on the console, and the service seems to get unregistered from the portmapper. Additional insights, anyone? -- Paul Kranenburg, Dept. C. Sc., Leiden University, NL.
jeffery@sys.caltech.edu (Jeffery Cavallaro) (05/20/89)
I noticed Paul Kranenburg's suggested source patches to selection_svc in v7i285. I don't have source. I just start selection_svc at boot time (rc.local) so root owns it. This seems innocent enough, and it works. Is there something wrong with this? Will this interfere with present or future windowing packages? Does selection_svc go away period under the SPARC/ABI scheme? Thanks, Jeff
kranenbu%HLERUL5I.BITNET@cunyvm.cuny.edu (05/24/89)
I forgot to mention that setting a signal-handler with signal(2) is of course bad SunView practice. This should really be done by using notify_set_signal_func(), but have not yet done that. I'll have to wait until everyone has gone home... Paul Kranenburg, Dept, C, Sc, Leiden, NL.
david@sun.com (Are we controlled by secret forces?) (05/27/89)
In article <8905091802.AA29608@SunWS5.rulcs.uucp> you write: >X-Sun-Spots-Digest: Volume 7, Issue 285, message 9 of 10 > >As mentioned in SunSpots v7n194, the selection_svc program hangs around >after exitting suntools. Since I started some experiments with customised >suntools executables this has become a major nuiscance, since installing a >new /usr/bin/suntools (late at night) invariably leads to swapping errors >(the next morning, in client selection_svc's which I forgot to kill).... Please note that this is not a good idea if any of your users run multiple suntools processes (on machines with multiple frame buffers or cg4s). All the tools will be using the first selection service started; if you kill it off along with one suntools process, the tools on the other desktop(s) will have no selection service. It can be very hard to recover from this. Why don't you just rename the old suntools process to "suntools-" before installing the new one? You could also make selection_svc a separate non-merged binary. I doubt that there are many pages shared between it and other toolmerge processes. [[ A selection_svc running as another user is also a security hole (or so I've been told). --wnl ]]
zeek@gamma.net.com (Jim Zeek) (08/08/90)
I get the following error when exiting suntools. It appears right after the login prompt that comes up. The usr does an exec csh (program1 program2 sleep 4) as the last thing in the .login. sparky login: selection_svc exiting: Hangup A return gives another login prompt. I realize that it is normal for this program to exit after suntools exits, but the I would like to know how to prevent it from appearing on the console. Any info would be appreciated.
wswietse@svbs01.bs.win.tue.nl (Wietse Venema) (08/09/90)
zeek@gamma.net.com (Jim Zeek) writes: >I get the following error when exiting suntools. It appears right after >the login prompt that comes up. >sparky login: selection_svc exiting: Hangup At the end of /etc/rc.local, we added a line with echo 'selection_svc&'| su nobody This makes the selection_svc 'resident' (improves sunview startup time) and als avoids some security problems. If nobody does not have an interactive shell, pick some other low-power user id.