Non-blocking version of system()

后端 未结 6 640
傲寒
傲寒 2020-12-09 03:24

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.

6条回答
  •  情深已故
    2020-12-09 03:34

    In the end, this code appears to work. Bit of a mis-mash of the above answers:

    pid = fork();
    
    if (!pid)
    {
        system("command here &");
    }
    
    exit(0);
    

    Not quite sure why it works, but it does what I'm after, thanks to everyone for your help

提交回复
热议问题