Reputation: 811
I am using linux to try and exec to run a different child process to parent process.
I can exec a child process to run the ps command fine.
int x = fork();
if (x == 0)
{
execl("/bin/ps","ps", NULL);
}
However as soon as I try to exec to a .exe file that I have created from my own c file like this gcc -v test.c -o test.exe
. by running this code:
int x = fork();
if (x == 0)
{
execl("/Desktop/test","test.exe", NULL);
}
Then nothing happens. If I printf the above execl
statement then it returns -1.
Can anyone let me know whats going on?
A few notes:
Upvotes: 0
Views: 1933
Reputation: 16041
The problem is, that your desktop folder is at ~/Desktop/
. The tilde means your home
folder.
Upvotes: 2