From owner-freebsd-current Thu Apr 18 11:51:54 2002 Delivered-To: freebsd-current@freebsd.org Received: from mail.pcnet.com (pcnet1.pcnet.com [204.213.232.3]) by hub.freebsd.org (Postfix) with ESMTP id D5D4837BB94 for ; Thu, 18 Apr 2002 11:48:17 -0700 (PDT) Received: from localhost (eischen@localhost) by mail.pcnet.com (8.12.1/8.12.1) with ESMTP id g3IIljt8004769; Thu, 18 Apr 2002 14:47:45 -0400 (EDT) Date: Thu, 18 Apr 2002 14:47:44 -0400 (EDT) From: Daniel Eischen To: Oswald Buddenhagen Cc: current@FreeBSD.org Subject: Re: thread pipe in libc_r In-Reply-To: <20020418171403.GB18271@ugly.homeip.net> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Thu, 18 Apr 2002, Oswald Buddenhagen wrote: > hi, > > heck, was it hard for me (a person who never used freebsd) to find the > right address ... nah, whatever. :) > > src/lib/libc_r/uthread/uthread_init.c > some time ago you commited a workaround for processes with pid 1 (and no > stdio). unfortunately, this won't catch programs started directly from > init (in my case it was kdm). they have no stdio set up as well, so they > will experience major havoc, too. i'm not sure about the check, though - > just test, if ppid == 1? > in my case the problem was building kdm with -pthread in the first place, > but still this should be fixed. Anyone know what to do for this problem? Here's what libc_r does for pid == 1: /* * Check for the special case of this process running as * or in place of init as pid = 1: */ if (getpid() == 1) { /* * Setup a new session for this process which is * assumed to be running as root. */ if (setsid() == -1) PANIC("Can't set session ID"); if (revoke(_PATH_CONSOLE) != 0) PANIC("Can't revoke console"); if ((fd = _thread_sys_open(_PATH_CONSOLE, O_RDWR)) < 0) PANIC("Can't open console"); if (setlogin("root") == -1) PANIC("Can't set login to root"); if (_thread_sys_ioctl(fd,TIOCSCTTY, (char *) NULL) == -1) PANIC("Can't set controlling terminal"); if (_thread_sys_dup2(fd,0) == -1 || _thread_sys_dup2(fd,1) == -1 || _thread_sys_dup2(fd,2) == -1) PANIC("Can't dup2"); } Is it valid to check for ppid == 1 and do the same thing? -- Dan Eischen To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message