Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 18 Nov 1999 20:02:01 -0800 (PST)
From:      Matthew Dillon <dillon@apollo.backplane.com>
To:        Luoqi Chen <luoqi@watermarkgroup.com>
Cc:        bde@zeta.org.au, current@FreeBSD.ORG, peter@netplex.com.au
Subject:   Re: init runs with console as control terminal?
Message-ID:  <199911190402.UAA90075@apollo.backplane.com>
References:   <199911190359.WAA06557@lor.watermarkgroup.com>

next in thread | previous in thread | raw e-mail | index | archive | help

:
:>     no control terminal == no signals == no ^C'ing hung programs during 
:>     startup (for example, when you need to boot a machine without a working
:>     network and sendmail and other programs stop the boot sequence in its
:>     tracks trying to do DNS lookups).
:> 
:> 					-Matt
:> 					Matthew Dillon 
:> 					<dillon@backplane.com>
:> 
:Hmm, good point. So I still need to find a way to start up rc5des, it seems
:that rc5des installs a SIGHUP handler and therefore nohup is useless. I wish
:there were a noctty...
:
:-lq

    Your wish is my command ... I needed the same thing for BEST for many
    things.  I call the program 'notty'.  Included below.

					-Matt
					Matthew Dillon 
					<dillon@backplane.com>



/*
 * NOTTY.C
 *
 * NOTTY [-012] <command>
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include <fcntl.h>
#include <signal.h>
#include <sys/ioctl.h>
#include <sys/time.h>
#include <sys/wait.h>

main(ac, av)
char *av[];
{
    char *opts = "";
    int ttyfd;

    if (av[1]) {
    	if (av[1][0] == '-') {
    	    opts = av[1];
    	    ++av;
	}
    }


    ttyfd = open("/dev/null", O_RDWR);

    if (strchr(opts, '0') == NULL && ttyfd != 0)
    	dup2(ttyfd, 0);
    if (strchr(opts, '1') == NULL && ttyfd != 1)
    	dup2(ttyfd, 1);
    if (strchr(opts, '2') == NULL && ttyfd != 2)
    	dup2(ttyfd, 2);

    if (ttyfd > 2)
    	close(ttyfd);

    {
	int fd = open("/dev/tty", O_RDWR);
	if (fd >= 0) {
	    ioctl(fd, TIOCNOTTY, 0);
	    close(fd);
	} 
    }

/*  signal(SIGCHLD, SIG_IGN); */
    if (fork() == 0) {
    	setpgrp();
	exit(execvp(av[1], av + 1));
    }
    exit(0);
}



To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-current" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199911190402.UAA90075>