Usenet comp.sys.dec (1990-2013)
 help / color / mirror / Atom feed
* Something kills me (-9) on a ^Z
@ 1997-07-15  4:00 Ron Natalie
  1997-07-16  4:00 ` Ron Natalie
  0 siblings, 1 reply; 3+ messages in thread
From: Ron Natalie @ 1997-07-15  4:00 UTC (permalink / raw)



Here's one that's bothered me for a while and I've never
been able to fully identify.  In our program we do a vfork
and then do 

	execl("/bin/sh", "sh", "-c", command, (char *)NULL);

If the "command" ends in "&" and the user subsequently types
^Z at the base application.  Something, I don't know what,
seems to send a signal 9 (kill) to the command started by
this shell.  Probably some esoteric process group thing,
but it only happens on the Digital UNIX, we've never seen
it on any other platform except that it also used to happen
on the SPIM ultrix.



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Something kills me (-9) on a ^Z
  1997-07-16  4:00 ` Ron Natalie
@ 1997-07-16  4:00   ` Ron Natalie
  0 siblings, 0 replies; 3+ messages in thread
From: Ron Natalie @ 1997-07-16  4:00 UTC (permalink / raw)


[-- Attachment #1: atest.c --]
[-- Type: text/plain, Size: 1242 bytes --]


#include <unistd.h>
#include <signal.h>

#define	FU_SUCCESS		0
#define FU_NULL_COMMAND		-1
#define FU_FORK_FAILS		-2
#define	FU_WAITPID_FAILS	-3

int
fork_unix(char *command, int *statloc)  {
    pid_t pid;
    int omask;
    void  (*intsave)(), (*quitsave)();

    if(!command) return FU_NULL_COMMAND;

#if SVR4_SIGNALS
    sighold(SIGCHLD);
#else
    omask = sigblock(sigmask(SIGCHLD));
#endif

    switch(pid = vfork()) {
    case -1:			/* error */
#if SVR4_SIGNALS
	sigrelse(SIGCHLD);
#else
	(void)sigsetmask(omask);
#endif
	return FU_FORK_FAILS;
    case 0:				/* child */
#if SVR4_SIGNALS
	sigrelse(SIGCHLD);
#else
	(void)sigsetmask(omask);
#endif
#if 0
	setsid();
#endif
	execl("/bin/sh", "sh", "-c", command, (char *)NULL);
	_exit(127);
    }
    intsave = signal(SIGINT, SIG_IGN);
    quitsave = signal(SIGQUIT, SIG_IGN);
    pid = waitpid(pid, (int *)statloc, 0);
#if SVR4_SIGNALS
    sigrelse(SIGINT);
    sigrelse(SIGQUIT);
    sigrelse(SIGHUP);
#else
    (void)sigsetmask(omask);
#endif
    (void)signal(SIGINT, intsave);
    (void)signal(SIGQUIT, quitsave);

    if(pid == -1)
	return FU_WAITPID_FAILS;
    else
	return FU_SUCCESS;
}



main() {
    int st;
    fork_unix("./x &", &st);

    while(1) {
	sleep(200);
    }
}




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Something kills me (-9) on a ^Z
  1997-07-15  4:00 Something kills me (-9) on a ^Z Ron Natalie
@ 1997-07-16  4:00 ` Ron Natalie
  1997-07-16  4:00   ` Ron Natalie
  0 siblings, 1 reply; 3+ messages in thread
From: Ron Natalie @ 1997-07-16  4:00 UTC (permalink / raw)



Just in case someone is inclined the program is attached.
I still suspect process group tom foolery.  A setpid in
the forked shell makes the problem go away, but I still
don't understand it.  If I capture the invoked program
with the debugger, something clearly sends it a signal
9 (SIGKILL).  This doesn't happen elsewhere.

The program "./x" is just a program that prints it's
pid and sleeps forever.

-Ron



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~1997-07-16  4:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1997-07-15  4:00 Something kills me (-9) on a ^Z Ron Natalie
1997-07-16  4:00 ` Ron Natalie
1997-07-16  4:00   ` Ron Natalie

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox