* Does init start with any open files?
@ 2012-12-25 7:38 bbi5291
2012-12-25 11:17 ` Borislav Petkov
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: bbi5291 @ 2012-12-25 7:38 UTC (permalink / raw)
To: linux-kernel
When the init process is created on system startup, does it have any
open file descriptors? If so, where do they point?
________________________________
Brian Bi
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Does init start with any open files?
2012-12-25 7:38 Does init start with any open files? bbi5291
@ 2012-12-25 11:17 ` Borislav Petkov
2012-12-25 11:25 ` bbi5291
2012-12-25 13:38 ` Miquel van Smoorenburg
2012-12-25 21:40 ` Rob Landley
2 siblings, 1 reply; 6+ messages in thread
From: Borislav Petkov @ 2012-12-25 11:17 UTC (permalink / raw)
To: bbi5291; +Cc: linux-kernel
On Tue, Dec 25, 2012 at 02:38:09AM -0500, bbi5291 wrote:
> When the init process is created on system startup, does it have any
> open file descriptors? If so, where do they point?
$ tree /proc/1/fd
/proc/1/fd
└── 10 -> /run/initctl
0 directories, 1 file
--
Regards/Gruss,
Boris.
Sent from a fat crate under my desk. Formatting is fine.
--
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Does init start with any open files?
2012-12-25 11:17 ` Borislav Petkov
@ 2012-12-25 11:25 ` bbi5291
2012-12-25 11:58 ` Borislav Petkov
0 siblings, 1 reply; 6+ messages in thread
From: bbi5291 @ 2012-12-25 11:25 UTC (permalink / raw)
To: Borislav Petkov, bbi5291, linux-kernel
Well, that can't be right---I grepped the kernel source for "initctl"
and got no results. Besides, if you're running a shell, then init has
already had time to open and close whatever file descriptors it wants
to. What I want to know is whether init has any open file descriptors,
at, say, the moment its main() starts executing.
________________________________
Brian Bi
On Tue, Dec 25, 2012 at 6:17 AM, Borislav Petkov <bp@alien8.de> wrote:
> On Tue, Dec 25, 2012 at 02:38:09AM -0500, bbi5291 wrote:
>> When the init process is created on system startup, does it have any
>> open file descriptors? If so, where do they point?
>
> $ tree /proc/1/fd
> /proc/1/fd
> └── 10 -> /run/initctl
>
> 0 directories, 1 file
>
> --
> Regards/Gruss,
> Boris.
>
> Sent from a fat crate under my desk. Formatting is fine.
> --
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Does init start with any open files?
2012-12-25 11:25 ` bbi5291
@ 2012-12-25 11:58 ` Borislav Petkov
0 siblings, 0 replies; 6+ messages in thread
From: Borislav Petkov @ 2012-12-25 11:58 UTC (permalink / raw)
To: bbi5291; +Cc: linux-kernel
First of all,
please do not top-post. You can search the net for why top-posting is
discouraged.
On Tue, Dec 25, 2012 at 06:25:11AM -0500, bbi5291 wrote:
> Well, that can't be right---I grepped the kernel source for "initctl"
> and got no results.
That's because it is a named pipe.
> Besides, if you're running a shell, then init has already had time
> to open and close whatever file descriptors it wants to. What I want
> to know is whether init has any open file descriptors, at, say, the
> moment its main() starts executing.
You probably want to stare at init/main.c:kernel_init() and what it
calls, and then download the sources of the init executable which is run
on your distro, whip up a text editor and start staring at them.
HTH.
--
Regards/Gruss,
Boris.
Sent from a fat crate under my desk. Formatting is fine.
--
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Does init start with any open files?
2012-12-25 7:38 Does init start with any open files? bbi5291
2012-12-25 11:17 ` Borislav Petkov
@ 2012-12-25 13:38 ` Miquel van Smoorenburg
2012-12-25 21:40 ` Rob Landley
2 siblings, 0 replies; 6+ messages in thread
From: Miquel van Smoorenburg @ 2012-12-25 13:38 UTC (permalink / raw)
To: bbi5291; +Cc: linux-kernel
In article <xs4all.CAMmfjbPKGD28070A0JvMyL02juYW5tuwNmVwrJ-1gFzkNhCuDQ@mail.gmail.com> you write:
>When the init process is created on system startup, does it have any
>open file descriptors? If so, where do they point?
0, 1 and 2, which are connected to the console. Boot a kernel with
"init=/bin/bash" and see for yourself.
Mike.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Does init start with any open files?
2012-12-25 7:38 Does init start with any open files? bbi5291
2012-12-25 11:17 ` Borislav Petkov
2012-12-25 13:38 ` Miquel van Smoorenburg
@ 2012-12-25 21:40 ` Rob Landley
2 siblings, 0 replies; 6+ messages in thread
From: Rob Landley @ 2012-12-25 21:40 UTC (permalink / raw)
To: bbi5291; +Cc: linux-kernel
On 12/25/2012 01:38:09 AM, bbi5291 wrote:
> When the init process is created on system startup, does it have any
> open file descriptors? If so, where do they point?
Last I checked, it worked like this:
If there's a /dev/console in initramfs, stdin, stdout, and stderr will
point to that. If you select no initramfs, you get one with just
/dev/console. If you create your own initramfs and don't put
/dev/console in it, init gets no file descriptors and there's a line
about it in dmesg.
Rob
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2012-12-25 21:40 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-12-25 7:38 Does init start with any open files? bbi5291
2012-12-25 11:17 ` Borislav Petkov
2012-12-25 11:25 ` bbi5291
2012-12-25 11:58 ` Borislav Petkov
2012-12-25 13:38 ` Miquel van Smoorenburg
2012-12-25 21:40 ` Rob Landley
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox