Search code examples
c++linuxmultithreadingbootautostart

Multithreaded application at boot sequence - C++/Debian


I'm having this obscure problem since 2 days : I created a launch-at-boot application in C++ on a debian system, which worked flawlessly until I integrated some multithreading elements.

  • There are only 2 threads (1 main and 1 child)
  • I included -lpthread and -pthread in the makefile
  • I tried both /.config/autostart and the .desktop file methods (same result)
  • The program is lanched with sudo
  • There is no error/crash anywhere, the main thread works OK, but the child thread runs 1 iteration only then stops for some reason
  • even tried to add some sleep in the lxsession boot sequence
  • If I launch the same command line than in the autostart file in a terminal (sudo or not), it works perfectly.

Its been 2 days and I just have NO CLUE ! If someone experienced this before or can find some logic in it, i'll be ever grateful.


Solution

  • Thank you all for your suggestions.

    I found a "fix" : running the startup program in a terminal ('@lxterminal -e url/to/program &' in autostart of lxsession) instead of background seems to fix it SOMEHOW. There is no GUI though ... it is a service.

    The multithreaded logic isnt at fault here, not my first shot, and I really want to keep this feature (@Mike Robinson).

    I will reconsider the use of sudo as suggested as well, which seems sketchy all things considered. It might get it running in background. thanks @ datenwolf.