From mboxrd@z Thu Jan 1 00:00:00 1970 From: =?ISO-8859-1?Q?Daniel_Nystr=F6m?= Date: Mon, 11 Apr 2011 12:25:39 +0200 Subject: [Buildroot] Starting programs in the background at init time: stdin EOF problem In-Reply-To: References: Message-ID: List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: buildroot@busybox.net Den 11 april 2011 11:53 skrev Thomas De Schampheleire : > Hej Daniel! > > 2011/4/11 Daniel Nystr?m : >> Hi Thomas! >> >> 2011/4/11 Thomas De Schampheleire : >>> What is the recommended way to start programs in such an embedded >>> environment? >> >> I'm using start-stop-daemon to perform similar tasks. Have you given >> it a try? It can "daemonize" even non-daemons which is pretty nice for >> e.g. GUI softwares. > > Thanks for the hint. > I just gave it a try as follows: > # start-stop-daemon ?-S -x ./shell ?--background > > Unfortunately, it seems to have the same problem. By daemonizing, the > file descriptor stdin seems to be closed, so my test program loops > forever (which I was able to visualize with strace). When your program is daemonized, it per se looses it's stdin/stdout. It sounds like a faulty design relying on those. > I may need to adapt my program to not use stdio, but rather other > filedescriptors. I suppose that they will not be impacted be > foreground/background issues? Fixing this design issue will probably help for future headaches as well. > Where do you start start-stop-daemon from? Directly from inittab or > from scripts in /etc/init.d? > How do you start other programs automatically? I'm starting them from /etc/init.d/. This is an example where it also handles the PID file writing as well: /sbin/start-stop-daemon --start --background --make-pidfile \ --pidfile /var/run/myprogram.pid --exec /usr/bin/myprogram And this will kill it the fair way: /sbin/start-stop-daemon --stop --oknodo --pidfile /var/run/myprogram.pid