From: Thomas De Schampheleire <patrickdepinguin+buildroot@gmail.com>
To: buildroot@busybox.net
Subject: [Buildroot] Starting programs in the background at init time: stdin EOF problem
Date: Mon, 11 Apr 2011 09:58:13 +0200 [thread overview]
Message-ID: <BANLkTi=Vx9c7OJ0arjwmrr6=WcTYFUfpyA@mail.gmail.com> (raw)
Hi,
I need to start a set of programs when the board boots. I'm using
scripts in /etc/init.d/ to accomplish this.
Since I shouldn't block the other inits, I put these programs in the
background. But, this seems to give problems for programs that read
from stdin: read immediately returns with EOF (return value 0).
For example, the following script:
/etc/init.d/S50shell
#!/bin/sh
/path/to/shell &
with the following 'shell' program:
#include <stdio.h>
#include <unistd.h>
int main (void)
{
int len;
char in[1];
while (1) {
printf("\n--> ");
len = read(0, in, 1);
write(1, in, len);
}
}
results in a continuous stream of "-->" to be printed at init time.
The read is supposed to be blocking, but returns prematurely because
end-of-file is detected on stdin.
If I do not put /path/to/shell in the background, the program works as expected.
What is the recommended way to start programs in such an embedded
environment? Besides this background problem, I also noticed problems
with using Ctrl-C depending on whether you start the program with a
init.d script (on /dev/console) or explicitly put it on a serial tty
in inittab.
Eventually, I would like to start a bunch of programs in the
background, and then present a login prompt to the user on the serial
tty.
Thanks,
Thomas
next reply other threads:[~2011-04-11 7:58 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-04-11 7:58 Thomas De Schampheleire [this message]
2011-04-11 8:55 ` [Buildroot] Starting programs in the background at init time: stdin EOF problem Daniel Nyström
2011-04-11 9:53 ` Thomas De Schampheleire
2011-04-11 10:25 ` Daniel Nyström
2011-04-14 7:29 ` Thomas De Schampheleire
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='BANLkTi=Vx9c7OJ0arjwmrr6=WcTYFUfpyA@mail.gmail.com' \
--to=patrickdepinguin+buildroot@gmail.com \
--cc=buildroot@busybox.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.