I have a C++ program that acts as a watchdog over others. If it detects that a process is no longer running, it restarts it via system
. The problem is, if I kil
You should avoid the use of system.
Do not use system() from a program with set-user-ID or set-group-ID privileges, because strange values for some environment variables might be used to subvert system integrity. Use the exec(3) family of functions instead.
and also if you want to check the return value or anything else
Just go for execl
#include
#include
pid_t pid = fork()
if (pid == -1)
{
exit(EXIT_FAILURE);
}
else if (pid == 0)
{
if (execl("processname", "processname", "/path/to/processConfig.xml", NULL) == -1)
exit(EXIT_FAILURE);
}
else
...