X Error with system()/fork()
While running my 'execute' ( execute("echo hi") ) function, I get this error:
Quote:
The execute function: Code:
void execute(const char *cmd) |
Instead of using system() after fork(), try using one of the exec() functions after fork().
|
or call exit() after youve run the command, although exec would be better. the problem is 2 processes are returning from your function both trying to access the Display* returned by XOpenDisplay which is confusing X.
|
exec appears more straightforward, but 'execlp("sh", "-c", "du -sh /", NULL)' says 'du -sh /: command not found'. I don't want to seperate the arguments myself as I don't know how many will be entered in.
Anyways, system() by itself with an '&' appears to work, but I keep getting random "Segmentation Fault"s. I think it is because I did not add the '&' properly. Also, while using fork(), do I have to worry about zombie processes or anything like that? Here is the function using 'execlp': Code:
void execute(const char *cmd) Code:
void execute(const char *cmd) |
All times are GMT -5. The time now is 06:11 PM. |