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 [EMAIL PROTECTED]
with "unsubscribe freebsd-current" in the body of the message

Reply via email to