[net.bugs.4bsd] remote processes started with rsh can be killed unintentionally

mp@allegra.UUCP (Mark Plotnick) (07/29/85)

...
Description:
	rsh will catch interrupt, quit, and soft kill signals, and propagate
	them to the remote process, even if those signals were being
	ignored, for example by having started the rsh in the background
	or with nohup.
	This is only a problem for /bin/sh users, since it doesn't
	place children in different process groups as the csh does.
Repeat-By:
	$ rsh presto "troff big-job" &
	$ [ at this point if you type ^C, the troff will be interrupted ]
Fix:
	
*** /tmp/rsh.c.old
--- /tmp/rsh.c
***************
*** 127,135
  	}
  	(void) setuid(getuid());
  	omask = sigblock(mask(SIGINT)|mask(SIGQUIT)|mask(SIGTERM));
! 	signal(SIGINT, sendsig);
! 	signal(SIGQUIT, sendsig);
! 	signal(SIGTERM, sendsig);
          pid = fork();
          if (pid < 0) {
  		perror("fork");

--- 127,138 -----
  	}
  	(void) setuid(getuid());
  	omask = sigblock(mask(SIGINT)|mask(SIGQUIT)|mask(SIGTERM));
! 	if(signal(SIGINT,SIG_IGN)!=SIG_IGN)
! 		signal(SIGINT, sendsig);
! 	if(signal(SIGQUIT,SIG_IGN)!=SIG_IGN)
! 		signal(SIGQUIT, sendsig);
! 	if(signal(SIGTERM,SIG_IGN)!=SIG_IGN)
! 		signal(SIGTERM, sendsig);
          pid = fork();
          if (pid < 0) {
  		perror("fork");


	Mark Plotnick
	allegra!mp

peter@graffiti.UUCP (Peter da Silva) (08/31/85)

> Repeat-By:
> 	$ rsh presto "troff big-job" &
> 	$ [ at this point if you type ^C, the troff will be interrupted ]

Would:
	$ rsh presto "troff big-job &"
Or:
	$ rsh presto "nohup troff big-job" &
Work as a workaround?

mouse@mcgill-vision.UUCP (der Mouse) (09/03/85)

> Repeat-By:
> 	$ rsh presto "troff big-job" &
> 	$ [ at this point if you type ^C, the troff will be interrupted ]

     This may not be a bug.  I believe rsh will have  your terminal open
in case you type something so it can get sent to the remote job (someone
correct me if sh  (I assume  sh  from the  $  prompt) uses /dev/null  or
something equally stupid for stdin for jobs run with &).  So the ^C  may
be doing exactly what it should.    I do know under 4.2bsd with the csh,
if  I try  to 'rsh  somehost  somecommand &' rsh  will  stop immediately
because  it  is in the  background  when  it tries to open the tty.  Try
doing

	rsh presto troff big-job < /dev/null

(don't  quote the < sign).  Then rsh  will get its  stdin from /dev/null
instead of your tty and *maybe* it will work.

		Maybe.
-- 
					der Mouse

{ihnp4,decvax,akgua,etc}!utcsri!mcgill-vision!mouse
philabs!micomvax!musocs!mcgill-vision!mouse

Hacker: One responsible for destroying /
Wizard: One responsible for recovering it afterward