Non-blocking version of system()

c, linux, operating-system

Solution

One option is in your system call, do this:

 system("ls -l &");

the & at the end of the command line arguments forks the task you've launched.

Problem

I want to launch a process from within my c program, but I don't want to wait for that program to finish. I can launch that process OK using system() but that always waits. Does anyone know of a 'non-blocking' version that will return as soon as the process has been started? [Edit - Additional Requirement] When the original process has finished executing, the child process needs to keep on running.

Original source