Re: 5.1 on a production box with some small problems (su, linux emu 7)

From: Karl M. Joch <k.joch_at_kmjeuro.com>
Date: Sat, 28 Jun 2003 18:12:39 +0200
arno,

thanks. i already found that patch posted somewhere on 
people.freebsd.org. but it hasnt helped. but thanks anyway.

i had that :
--- su.c.orig	Sat Jun 28 17:52:21 2003
+++ su.c	Sat Jun 28 17:57:13 2003
_at__at_ -359,6 +359,8 _at__at_
  	child_pid = fork();
  	switch (child_pid) {
  	default:
+		sa.sa_handler = SIG_IGN;
+		sigaction(SIGTTOU, &sa, NULL);
  		close(fds[0]);
  		setpgid(child_pid, child_pid);
  		tcsetpgrp(1, child_pid);
_at__at_ -366,7 +368,9 _at__at_
  		sigaction(SIGPIPE, &sa_pipe, NULL);
  		while ((pid = waitpid(child_pid, &statusp, WUNTRACED)) != -1) {
  			if (WIFSTOPPED(statusp)) {
-				kill(getpid(), SIGSTOP);
+				if (WSTOPSIG(statusp) != SIGTTOU &&
+				    WSTOPSIG(statusp) != SIGTTIN)
+					kill(getpid(), SIGSTOP);
  				child_pgrp = getpgid(child_pid);
  				tcsetpgrp(1, child_pgrp);
  				kill(child_pid, SIGCONT);


arno_at_heho.snv.jussieu.fr wrote:
> Karl,
> 
> 
>>i run 5.1 on one of the inhouse production boxes successful. there are
>>only 2 small points witch are a pain and i found no solution. box was
>>fresh setup with 5.0 then cvsuped to 5.1.
>>
>>1. when starting some scripts su doesnt return from the shell and
>>hangs on boot. when starting manually i get "tty output stopped". with
>>exit there is a way out of this shell, but i havnt found a
>>solution. most of the scripts runs since 3.x, at least 4.x and was
>>working up to 4.8. one of this scripts is the pervasive sql server
>>startup script which is part of the pervasive server for linux. using
>>#!/compat/linux/bin/sh doesnt help. there are 2 lines in it starting
>>sqlmgr and psql with:
>>echo "commands...." | /bin/su - psql || exit 1
>>after the 1st one tty output is stopped. the other script is vmware
>>and vncserver related and uses linux emu too.
> 
> 
> I had a similar problem, which has been solved by the following
> patch posted by David Xu (not white-space clean), you might
> give it a try.
> 
> Arno
> 
> #####
> Index: usr.bin/su/su.c
> ===================================================================
> RCS file: /home/ncvs/src/usr.bin/su/su.c,v
> retrieving revision 1.68
> diff -c -r1.68 su.c
> *** usr.bin/su/su.c     8 Apr 2003 16:59:53 -0000       1.68
> --- usr.bin/su/su.c     28 Jun 2003 10:33:17 -0000
> ***************
> *** 359,364 ****
> --- 359,366 ----
>         child_pid = fork();
>         switch (child_pid) {
>         default:
> +                 sa.sa_handler = SIG_IGN;
> +                 sigaction(SIGTTOU, &sa, NULL);
>                 close(fds[0]);
>                 setpgid(child_pid, child_pid);
>                 tcsetpgrp(1, child_pid);
> ***************
> *** 366,372 ****
>                 sigaction(SIGPIPE, &sa_pipe, NULL);
>                 while ((pid = waitpid(child_pid, &statusp, WUNTRACED)) != -1) {
>                         if (WIFSTOPPED(statusp)) {
> !                               kill(getpid(), SIGSTOP);
>                                 child_pgrp = getpgid(child_pid);
>                                 tcsetpgrp(1, child_pgrp);
>                                 kill(child_pid, SIGCONT);
> --- 368,376 ----
>                 sigaction(SIGPIPE, &sa_pipe, NULL);
>                 while ((pid = waitpid(child_pid, &statusp, WUNTRACED)) != -1) {
>                         if (WIFSTOPPED(statusp)) {
> !                                 if (WSTOPSIG(statusp) != SIGTTOU && 
> !                                     WSTOPSIG(statusp) != SIGTTIN)
> !                                         kill(getpid(), SIGSTOP);
>                                 child_pgrp = getpgid(child_pid);
>                                 tcsetpgrp(1, child_pgrp);
>                                 kill(child_pid, SIGCONT);


-- 
Best regards / Mit freundlichen Gruessen,

Karl M. Joch
k.joch_at_ctseuro.com
http://www.ctseuro.com
Received on Sat Jun 28 2003 - 07:12:50 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:37:13 UTC