[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Monit doesn't detach from the tty
From: |
Rory Toma |
Subject: |
Re: Monit doesn't detach from the tty |
Date: |
07 Aug 2002 17:40:39 -0700 |
Which brings up 2 more questions...
1) why use _exit(0) instead of exit(0)?
2) I noticed that we also keep fd 0, 1 and 2 open. Generally, I've used
dup2 to copy 0 1 and 2 to and closed them off.
On Wed, 2002-08-07 at 17:23, Mark Ferlatte wrote:
> 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
--
Rory Toma address@hidden
VP of Run Level 5 http://www.trs80.net
Digeo Digital http://www.digeo.com
signature.asc
Description: This is a digitally signed message part
- Monit doesn't detach from the tty, Mark Ferlatte, 2002/08/07
- Re: Monit doesn't detach from the tty,
Rory Toma <=
- Re: Monit doesn't detach from the tty, Mark Ferlatte, 2002/08/07
- Re: Monit doesn't detach from the tty, Rory Toma, 2002/08/07
- postfix, anyone, Rory Toma, 2002/08/07
- Re: postfix, anyone, Igor Homyakov, 2002/08/08
- Re: postfix, anyone, rory, 2002/08/08
- Re: postfix, anyone, Christian Hopp, 2002/08/08
- Re: postfix, anyone, rory, 2002/08/08
- Re: postfix, anyone, Mark Ferlatte, 2002/08/08
- Re: Monit doesn't detach from the tty, Rory Toma, 2002/08/07
Re: Monit doesn't detach from the tty, Jan-Henrik Haukeland, 2002/08/07