0

I have my own embedded Linux system on PocketBeagle board. I have developed a simple gpio application in C that issues an on/off command to one of the pins of the connectors of the board. The application is called gpio_aa6 and located at /root. The first challenge was to find a way to launch my application automatically after booting the board. I found two ways to do that; the first was to add an entry to etc/rcS directory. This entry is a simple script file that launches my application. The second way was to edit /etc/inittab file and add an entry to that file (::respawn:/root/gpio_aa6). In both these ways my application was launched successfully: but I am still not sure if this is the right way to launch my application automatically. Then I came to the second challenge, how can I stop my running application, as the respawn re-launches the application if it's terminated? I am communicating with the board in two ways; via a serial communication (using screen terminal) and via web sever (root@192.168.42.2). I have tried to use Ctrl+C, Ctrl+Z, Ctrl+\, but couldn't stop the program from being continue running. Then I used command "killall" with killsignals -9 or -15, it seems that the program is interrupted but it's launched again directly after that.

My application is to run infinitely, but I need to stop it sometimes to update it and re-launch it again.

Is there any suggestion how to overcome this problem? Thanks.

AA Son
  • 23
  • 1
  • 7

1 Answers1

1

Both solutions you have used are correct. I personally prefer the option of adding an init script to /etc/init.d though.

I believe the behavior that you observe that you apparently can't kill the program is because you are starting your program from inittab, with the respawn keyword, which precisely tells the init program to restart your application when it exits. If you actually check the PID of your application, you will see that it changes everytime you kill it.

Therefore, I would recommend you to use an init script instead, with which you can implement start and stop actions. See ./package/lldpd/S60lldpd for a basic example in Buildroot.

Thomas Petazzoni
  • 5,636
  • 17
  • 25