[systemd-devel] [systemd-commits] 2 commits - TODO src/core src/shared

Lennart Poettering lennart at poettering.net
Tue Feb 3 17:30:28 PST 2015


On Wed, 04.02.15 02:23, Zbigniew Jędrzejewski-Szmek (zbyszek at in.waw.pl) wrote:

> > Sounds OK to me. Question is how to check this best... 
> > 
> > Maybe check with get_ctty_devnr() if we have a controlling tty? 
>
> If I launch 'systmectl' in a script from the command line, I'd prefer it not
> to be in debug mode either. 

checking the controlling tty would achieve that. Note that you cannot
accidentally lose your controlling tty. Even if you use shell
redirection to disconnect a process' stdin, stdout, stderr away from a
tty, it will still keep it as ctty (that's why SIGINT is still
delivered to a process on C-c, even if you disconnect all its fds from
the tty). The only way to really get rid of your ctty is by calling
setsid() or invoking TIOCNOTTY, but this is precisely what daemons do,
not what normal commands do. Hence I think get_ctty_devnr() is a
really good choice for this...

> Maybe something like
> org.freedesktop.systemd1.Manager.GetUnitByPID(getpid()) not being a
> .scope?

Hmm, I really wouldn't want to involve dbus here, after all we'd use
it in pretty much all code...

Also, scope units are used for other purposes too, like
"systemd-run"...

Also, I think that debug mode should even be enabled for user daemons
as long as they are not controlled directly by terminals...

Lennart

-- 
Lennart Poettering, Red Hat


More information about the systemd-devel mailing list