I’m writing a C/C++ program that I’d like to have run when a user logs on to their Mac or Linux machine.
I’m thinking of starting my app when kernel finishes loading. This app will be listen user login signal. When it receives the signal, it will then run my other app.
Is this a good strategy? Is there a better way to have my app automatically run when a user logs on to their machine?
Yes, there are better ways:
For Mac OS X you want to use
launchd(8). (See Apple’s Daemons and Services Programming Guide and the man page forlaunchd(8).)For KDE there is Autostart.
For Gnome you can use the Default Session or the system wide Configuration of the GNOME Display Manager.
In the old days of X11 there used to be a file called
.xinitrc(see the man page forxinit(1)) or.xsession(see the man page forxdm(1)).