I have a daemon process, set up using launchd on Mac. The daemon is running as root. The following line does not launch my UI application -
system("launchctl start com.project.myproj");
But if I go to the terminal and run the same command -> launchctl start com.project.myproj. It launches my application. My question is am i doing something wrong or is system not behaving correctly ?
The problem is that launch daemons started by the system don't have access to Aqua, so your daemon process can't access the desktop environment.
Apple's Technical Note TN2083: Daemons and Agents describes some of this. (See this section on launchd agents.)
Someone asked a similar question about accessing the Aqua environment from an SSH connection.
I'm guessing you need to re-architect your application a bit: