How to force C program exit after execlp() while child process still running?
- User
How to force C program exit after execlp() while child process still running?
- Assistant
When you use
execlp()in a C program, it replaces the current process image with a new process image specified by the arguments you provide. This means that after callingexeclp(), the original process (the parent) will no longer exist in the traditional sense—it's replaced by the new executable.However, if you want the parent process to terminate while the child process continues running after executing a new program with , you need to create a forked child process. Here's how you can achieve that: