0

I'm trying to figure out how do I develop a cross platform program that will run in the background and will work once the system has started.

I want to cover windows and Linux only. I know that there's no such thing as a thread and there are only processes. So.. in Linux I need to make a daemon program or a service in Windows.

I know how each of them works in logical way but I don't have an idea how to write it.

I will appreciate every help I could get. Thanks!

Ido Magor
  • 544
  • 1
  • 5
  • 14
  • 1
    Did you try asking Google? [This SO post](http://stackoverflow.com/questions/3095566/linux-daemonize) summarises the steps for Linux. I'm sure similar answers exist for Windows. – Andrew Jan 12 '16 at 13:43

1 Answers1

-1

You simply need to run your program after system start. It's not related to threads and stuff.

Wrap OS-specific stuff in

#if defined _WIN32
    #include <windows.h>
    int ret = ShellExecute(hwnd, "runas", "see link below for windows", NULL, "c:\\windows\\system", SW_SHOWNORMAL );
#elif defined __linux__
     int ret = system("see link for linux");
#else
     #error Err
#endif

Link for Windows

Link for Linux - for linux case you need to call several commands to create startup scripts and add them to chkconfig

Community
  • 1
  • 1
Starl1ght
  • 4,422
  • 1
  • 21
  • 49