user3001499
user3001499

Reputation: 811

C: exec to my own exe file

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:

  1. the test.exe file (created from my c source code) icon shows up a windows icon (why, and is this the problem?)
  2. When running test from terminal it executes fine

Upvotes: 0

Views: 1933

Answers (1)

meskobalazs
meskobalazs

Reputation: 16041

The problem is, that your desktop folder is at ~/Desktop/. The tilde means your home folder.

Upvotes: 2

Related Questions