* Writing as init without /dev/console?
@ 2005-06-20 13:51 Nico Schottelius
2005-06-23 8:27 ` Miquel van Smoorenburg
0 siblings, 1 reply; 2+ messages in thread
From: Nico Schottelius @ 2005-06-20 13:51 UTC (permalink / raw)
To: linux-kernel
[-- Attachment #1: Type: text/plain, Size: 1613 bytes --]
Hello!
Currently I do not open /dev/console in cinit, but currently
I do see very strange behaviour:
If the first printf() in the following code (from serv/cinit.c) is
enabled, the socket communication will later fail:
----------------------------------------------------------------------
#ifdef DEBUG
// printf("ARGC=%d\n",argc);
#endif
set_signals(ACT_SERV); /* set signal handlers */
#ifdef DEBUG
printf("ARGC=%d\n",argc);
#endif
----------------------------------------------------------------------
I don't know what could be the relation between this printf and the
behaviour that cinit-0.1 later hangs in comm/do_result when reading
the resulting byte from a socket.
If you want to see the full code, it can be found at [0].
This code contains serv/cinit.c, which is the same as found
in cinit-0.0.8 [1] and serv/cinit.c-cinit0.1, which is the one
with a bit more debugging and the printf() before set_signals,
which makes cinit hang in comm/do_result at the position when
fpoint() is called.
Perhaps this is an issue with not opening /dev/console? It's just
a guess, because I don't have any idea what could cause this behaviour.
If someone has _any_ idea, I would be very thankful.
Nico
[0]: http://creme.schottelius.org/~nico/pre-release/cLinux/cinit-0.1-rc4.tar.bz2
P.S.: I do read replies to the mailing list via web-interface, replies
to me must be confirmed otherwise.
--
Keep it simple & stupid, use what's available.
Please use pgp encryption: 8D0E 27A4 is my id.
http://nico.schotteli.us | http://linux.schottelius.org
[-- Attachment #2: Type: application/pgp-signature, Size: 827 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Writing as init without /dev/console?
2005-06-20 13:51 Writing as init without /dev/console? Nico Schottelius
@ 2005-06-23 8:27 ` Miquel van Smoorenburg
0 siblings, 0 replies; 2+ messages in thread
From: Miquel van Smoorenburg @ 2005-06-23 8:27 UTC (permalink / raw)
To: linux-kernel
In article <20050620135132.GB2779@schottelius.org>,
Nico Schottelius <nico-kernel@schottelius.org> wrote:
>Currently I do not open /dev/console in cinit, but currently
>I do see very strange behaviour:
>
>If the first printf() in the following code (from serv/cinit.c) is
>enabled, the socket communication will later fail:
printf() prints to stdout i.e. filedescriptor #1. If you do not
open stdin/stdout/stderr in your program, you do not know what
is going to be fd #1 later on .. in your case, the socket probably
is fd #1 and the printf() is happily printing to it.
To prevent this, do something like this at the start of your program:
int n;
do {
n = open("/dev/null", O_RDWR);
} while (n >= 0 && n <= 2);
close(n);
Mike.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2005-06-23 8:48 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-06-20 13:51 Writing as init without /dev/console? Nico Schottelius
2005-06-23 8:27 ` Miquel van Smoorenburg
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®