Re: how to find out the current tty from a daemon?
From: Joe Beanfish (joebeanfish_at_nospam.duh)
Date: Thu, 07 Aug 2003 13:44:20 -0400
Andrej Hocevar wrote:
> In article <uUbYa.641762$3C2.email@example.com>, Andrew Taylor wrote:
> > What do you mean by the "current tty"? Usually daemons will detach from
> > their tty with a TIOCNOTTY ioctl. If you want to log information to the
> > console, you probably want to write it directly to /dev/console, or
> > better yet, use syslogd and direct the output to the appropriate place
> > in /etc/syslog.conf.
> OK, I need to be more precise. Here's what I'm trying to do. I have
> my daemon lurking in the background (forked twice), waiting for the
> user to take some specified action (move the mouse wheel). When it
> happens, it is supposed to send an event to the _user's_ current
> console with an ioctl call. Unfortunatelly, it only works for the
> console I start it on; however, eventually, init might start it in
> the future so even that won't work anymore. So I need a way to get
> the name of the tty the user is currently using. (This is not meant
> for X.)
> After some thinking, this became unclear even to myself.
You're reinventing gpm. See