Question

I'm writing an application for an embedded busybox system that allows TCP connections, then sends out messages to all connected clients. It works perfectly when I telnet to the box and run the application from a shell prompt, but I have problems when it is launched from the inittab. It will launch and I can connect to the application with one client. It successfully sends one message out to that client, then crashes. It will also crash if I connect a second client before any messages are sent out. Again, everything works perfectly if I launch it from a shell prompt instead.

The following errors are what comes up in the log:

<11>Jan  1 00:02:49 tmmpd.bin: ERROR: recvMessage failed, recv IO error 
<11>Jan  1 00:02:49 tmmpd.bin: Some other LTK TCP error 103. Closing connection 10 
<11>Jan  1 00:02:49 tmmpd.bin: ERROR: recvMessage failed, recv IO error 
<11>Jan  1 00:02:49 tmmpd.bin: Some other LTK TCP error 103. Closing connection 10 

Any suggestions would be greatly appreciated!

Was it helpful?

Solution

I was testing a bit in arm-qemu and busybox, and I was able to start a script as user test to run in background.

I have created a new user "test":

buildroot-dir> cat etc/passwd
test:x:1000:1000:Linux User,,,:/home/test:/bin/sh

Created a simple testscript.sh:

target_system> cat /home/test/testscript.sh
#!/bin/sh

while :
do
    echo "still executing in bg"
    sleep 10
done

To my /etc/init.d/rcS I added a startup command for it:

#!/bin/sh
mount -t proc none /proc
mount -t sysfs none /sys
/sbin/mdev -s

/bin/su test -c /home/test/testscript.sh& # < Added this

Now when I start the system, the script will run in the background, and when I grep for the process it has been started as user test (default root user is just 0):

target_system> ps aux | grep testscript
496 test    0:00 sh -c home/test/testscript.sh
507 test    0:00 {testscript.sh} /bin/sh home/test/testscript.sh
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top