monit-general
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Monit doesn't detach from the tty


From: Mark Ferlatte
Subject: Monit doesn't detach from the tty
Date: Wed, 7 Aug 2002 17:23:10 -0700
User-agent: Mutt/1.4i

Heh, I'm back, fresh from the umask issue (BTW, I'm running a copy of
monit that does umask save at startup/restore at spawn, and it, at
least, does what I want... ;), and found another one.

monit 2.5, when run in daemon mode, doesn't actually detach from the
tty, which results in (at least) ssh having trouble when you try and log
out.

Empirical evidence:

protagonist:~# fuser /dev/pts/6
/dev/pts/6:           3453  3662
protagonist:~# /etc/init.d/monit start
Starting daemon monitor: monit.
protagonist:~# fuser /dev/pts/6
/dev/pts/6:           3453  3667  3675
protagonist:~# ps ax | grep 3667
 3667 ?        S      0:00 /usr/sbin/monit -c /etc/monit/monitrc
 3679 pts/6    S      0:00 grep 3667


Upon looking in daemonize.c:daemonize(), it looks like either you need
to fork() again after setsid(), or do

fd = open("/dev/tty", O_RDONLY);
if (fd != -1) {
        if (ioctl(fd, TIOCNOTTY) == -1) {
                /* print some error about being unable to detach from
                   tty properly */
        }
        (void) close(fd);
}

I have a feeling that the double fork method is much more portable, so
you probably want to do that instead of the ioctl.

M

Attachment: pgp2Awea_L2b1.pgp
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]