2002-01-30 16:25:06

by Wartan Hachaturow

[permalink] [raw]
Subject: Console driver behaviour?

Hello.

How can I determine that the program is run via ssh or on
a headless box?
The problem is with Linux Console Tools. It tries opening
/dev/tty, /dev/tty0 and /dev/console respectively upon the
start, and it fails on ssh'ed or headless boxes. Is there
any way to catch the situation? I've thought that open should
return ENODEV in these cases, but it doesn't..

--
Regards, Wartan.
"Computers are not intelligent. They only think they are."


2002-01-30 20:57:37

by Wartan Hachaturow

[permalink] [raw]
Subject: Re: Console driver behaviour?

On Wed, Jan 30, 2002 at 03:09:07PM -0500, Mark Hahn wrote:

> > any way to catch the situation? I've thought that open should
> > return ENODEV in these cases, but it doesn't..
>
> screen, perhaps? this is most definitely not a linux-kernel question.

This is most probably a console driver question, which is
kernel-specific ;)
I wonder what should console driver say when it doesn't have a real physical
console behind it. IMO, this should be a ENODEV case, or some other way
to determine programmatically that this situation takes place.
So, I am trying to find someone familar with console driver on
linux-kernel (since this driver doesn't have a specific maintainer).

If I am wrong, and linux-kernel is not relevant, sorry..

--
Regards, Wartan.
echo "Your stdio isn't very std."
-- Larry Wall in Configure from the perl distribution

2002-02-01 00:45:19

by James Simmons

[permalink] [raw]
Subject: Re: Console driver behaviour?


> > > any way to catch the situation? I've thought that open should
> > > return ENODEV in these cases, but it doesn't..
> >
> > screen, perhaps? this is most definitely not a linux-kernel question.
>
> This is most probably a console driver question, which is
> kernel-specific ;)
> I wonder what should console driver say when it doesn't have a real physical
> console behind it. IMO, this should be a ENODEV case, or some other way
> to determine programmatically that this situation takes place.

That should not happen. Especially since int init/main.c we have:

if (open("/dev/console", O_RDWR, 0) < 0)
printk("Warning: unable to open an initial console.\n");

(void) dup(0);
(void) dup(0);

which causes alot of problems.

> So, I am trying to find someone familar with console driver on
> linux-kernel (since this driver doesn't have a specific maintainer).

That would be me :-/

2002-02-01 00:49:19

by James Simmons

[permalink] [raw]
Subject: Re: Console driver behaviour?


> How can I determine that the program is run via ssh or on
> a headless box?

Hm. I never seen a clean way to do this :-(

> The problem is with Linux Console Tools. It tries opening
> /dev/tty, /dev/tty0 and /dev/console respectively upon the
> start, and it fails on ssh'ed or headless boxes. Is there
> any way to catch the situation? I've thought that open should
> return ENODEV in these cases, but it doesn't..

/dev/console -> System console. printk messages are sent to these devices.
It is always there.

/dev/tty -> The TTY device associated with the current process

/dev/tty0 -> Only related to VTs. This is the foreground virtual
termial (made from a graphics card and a regular keyboard)