【问题标题】:Application crashes only when launched from inittab on busybox仅当从busybox 上的inittab 启动时应用程序才会崩溃
【发布时间】:2014-04-10 00:08:07
【问题描述】:

我正在为嵌入式busybox 系统编写一个应用程序,该系统允许TCP 连接,然后向所有连接的客户端发送消息。当我 telnet 到盒子并从 shell 提示符运行应用程序时,它工作得很好,但是从 inittab 启动它时我遇到了问题。它将启动,我可以使用一个客户端连接到应用程序。它成功地向该客户端发送了一条消息,然后崩溃。如果我在发送任何消息之前连接第二个客户端,它也会崩溃。同样,如果我从 shell 提示符启动它,一切都会完美运行。

日志中出现以下错误:

<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 

任何建议将不胜感激!

【问题讨论】:

    标签: c linux tcp busybox


    【解决方案1】:

    我在arm-qemubusybox 中进行了一些测试,我能够启动一个脚本作为用户测试在后台运行。

    我创建了一个新用户“test”:

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

    创建了一个简单的testscript.sh

    target_system> cat /home/test/testscript.sh
    #!/bin/sh
    
    while :
    do
        echo "still executing in bg"
        sleep 10
    done
    

    我为我的/etc/init.d/rcS 添加了一个启动命令:

    #!/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
    

    现在当我启动系统时,脚本将在后台运行,当我对进程进行 grep 时,它已以用户 test 启动(默认 root 用户只是 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
    

    【讨论】:

    • 我试过这个,但没有运气。当我尝试在 inittab 中使用 su 时,它似乎根本没有启动。事实上,我什至不确定 su 在这个busybox 实现中是否可用……因为它是一个嵌入式设备,所以它非常精简。
    • @DrRocket 我折腾了一下,现在有一个可以在运行 arm 内核和busybox rootfs 的测试qemu 系统上运行的工作解决方案,试试看!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-11-05
    • 1970-01-01
    • 2013-08-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多