Ask a Question related to UNIX Programming, Design and Development.
-
Andrej Hocevar #1
how to find the current tty?
Hello,
I'm trying to find out how I can tell the current tty from a daemon
written in C. ttyname() is useful only for the tty I start it on, but
how should I do it after that? Besides, ttyname() doesn't help if I
close fds 0, 1 and 2. I'm running Linux.
Any ideas?
Thanks,
andrej
--
echo ${girl_name} > /etc/dumpdates
Andrej Hocevar Guest
-
Using DW find to find tags not on page
I transfering content from 1498 static pages into a MySQL database. I've isolated 1450 pages with single h1 or h2 tags that I can use in the title... -
Either BOF or EOF is True, or the current record hasbeen deleted. Requested operation requires a current record
Can anyone pls help? I am getting the following error when search my database. "ADODB.Field (0x800A0BCD Either BOF or EOF is True, or the... -
trailing slash issue in Find.find
require "find" Find.find("/usr/bin/") { |file| puts file } /usr/bin//rmdir /usr/bin//rm /usr/bin//mv /usr/bin//mknod /usr/bin//mkfifo... -
highlight current row?
developer 6 win and mac In list view I want to highlight the current row with a color. I know it is done with a container field and a graphic color... -
How to change the current thread current culture at run time.
I have created a new culture : Dim objCulture As New CultureInfo("he") //hebrew When I tried to assign it to the current thread. ... -
Barry Margolin #2
Re: how to find the current tty?
In article <slrnbj2geq.1m3.drejcica@sonet.utopija.linux>,
Andrej Hocevar <drejcica@volja.net> wrote:A daemon doesn't usually have a current tty, so what are you expecting to>Hello,
>I'm trying to find out how I can tell the current tty from a daemon
>written in C. ttyname() is useful only for the tty I start it on, but
>how should I do it after that? Besides, ttyname() doesn't help if I
>close fds 0, 1 and 2. I'm running Linux.
get?
--
Barry Margolin, [email]barry.margolin@level3.com[/email]
Level(3), Woburn, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.
Barry Margolin Guest
-
Marc Rochkind #3
Re: how to find the current tty?
On Wed, 06 Aug 2003 17:53:27 GMT, Andrej Hocevar <drejcica@volja.net>
wrote:
> Hello,
> I'm trying to find out how I can tell the current tty from a daemon
> written in C. ttyname() is useful only for the tty I start it on, but
> how should I do it after that? Besides, ttyname() doesn't help if I
> close fds 0, 1 and 2. I'm running Linux.
> Any ideas?
>
> Thanks,
>
> andrej
>
A bit more precison is needed... the system maintains a "control terminal"
for each process (possibly non-existent) that you can retrieve with
ctermid, but that's likely to just return the string "/dev/tty" -- perhaps
that is OK.
Or if you mean something else by "current tty," could you explain a bit
more?
--Marc
Marc Rochkind Guest
-
Rich Teer #4
Re: how to find the current tty?
On Wed, 6 Aug 2003, Andrej Hocevar wrote:
Umm, daemons don't have a "current tty". WHat are you trying> I'm trying to find out how I can tell the current tty from a daemon
> written in C. ttyname() is useful only for the tty I start it on, but
> how should I do it after that? Besides, ttyname() doesn't help if I
> close fds 0, 1 and 2. I'm running Linux.
to achieve?
--
Rich Teer, SCNA, SCSA
President,
Rite Online Inc.
Voice: +1 (250) 979-1638
URL: [url]http://www.rite-online.net[/url]
Rich Teer Guest
-
Andrej Hocevar #5
Re: how to find the current tty?
In article <9ubYa.65$Mg5.1@news.level3.com>, Barry Margolin wrote:
Right. Either my question was not precise enough or my concept was> A daemon doesn't usually have a current tty, so what are you expecting to
> get?
somehow wrong. 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.
After some thinking, this became unclear even to myself.
But I took a look at the kernel sources (2.4.20) and found this in
the drivers/char/console.c file:
/*
* fg_console is the current virtual console,
* last_console is the last used one,
* want_console is the console we want to switch to,
* kmsg_redirect is the console for kernel messages,
*/
int fg_console;
int last_console;
int want_console = -1;
int kmsg_redirect;
Clearly, something like that is used when alt-left_arrow is pressed
to switch to the next tty.
I'm sure now that there must be a way of getting the information I
need, but probably with another approach.
Has anyone got any ideas?
Thanks,
andrej
--
echo ${girl_name} > /etc/dumpdates
Andrej Hocevar Guest
-
Andrej Hocevar #6
Re: how to find the current tty?
In article <_%tYa.4$7R.3@news.level3.com>, Barry Margolin wrote:
It does make sense -- only not in X, which I don't want, anyway.> This doesn't make sense. If the user has 5 xterm windows open, he's using
> 5 tty's.
--
echo ${girl_name} > /etc/dumpdates
Andrej Hocevar Guest
-
Marc Rochkind #7
Re: how to find the current tty?
On Thu, 07 Aug 2003 09:38:08 GMT, Andrej Hocevar <drejcica@volja.net>
wrote:
[snip]> In article <9ubYa.65$Mg5.1@news.level3.com>, Barry Margolin wrote:>>> A daemon doesn't usually have a current tty, so what are you expecting
>> to
>> get?
> Right. Either my question was not precise enough or my concept was
> somehow wrong. 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.
>
There are some records kept, which are used by the who command.
Look at the documentation for getutxent and the header utmpx.h. Maybe this
is what you're looking for. But, as I think Barry pointed out, these
records don't necessarily tell you exactly what tty the user is using, only
how he or she logged in.
--Marc
Marc Rochkind Guest
-
Barry Margolin #8
Re: how to find the current tty?
In article <slrnbj50ai.hh.drejcica@sonet.utopija.linux>,
Andrej Hocevar <drejcica@volja.net> wrote:If he's not running a window system, but he's using the system console,>In article <_%tYa.4$7R.3@news.level3.com>, Barry Margolin wrote:>>> This doesn't make sense. If the user has 5 xterm windows open, he's using
>> 5 tty's.
>It does make sense -- only not in X, which I don't want, anyway.
then /dev/console is probably the device you want.
--
Barry Margolin, [email]barry.margolin@level3.com[/email]
Level(3), Woburn, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.
Barry Margolin Guest
-
Floyd Davidson #9
Re: how to find the current tty?
Barry Margolin <barry.margolin@level3.com> wrote:
This question was multiposted to several groups, and hence has>In article <slrnbj50ai.hh.drejcica@sonet.utopija.linux>,
>Andrej Hocevar <drejcica@volja.net> wrote:>>>In article <_%tYa.4$7R.3@news.level3.com>, Barry Margolin wrote:>>>>> This doesn't make sense. If the user has 5 xterm windows open, he's using
>>> 5 tty's.
>>It does make sense -- only not in X, which I don't want, anyway.
>If he's not running a window system, but he's using the system console,
>then /dev/console is probably the device you want.
split the discussion in a very unproductive way.
He is using Linux, has multiple virtual consoles, and apparently
wants the functionality of gpm, where he is intercepting the
mouse (or in his case possibly the keyboard too) and needs to
know which vc is actually being displayed on the system monitor.
Despite the fuzzy responses, it appears that in some newsgroups
others have narrowed it down to what he does want and are
attempting to explain where he can find examples.
Perhaps the best thing in this newsgroup would be to just drop
the thread and ignore it.
--
Floyd L. Davidson <http://web.newsguy.com/floyd_davidson>
Ukpeagvik (Barrow, Alaska) [email]floyd@barrow.com[/email]
Floyd Davidson Guest



Reply With Quote

