S
S
sitev_ru2016-07-26 08:48:20
linux
sitev_ru, 2016-07-26 08:48:20

Why does execl exit the process?

I fork the process, in it I run another program with the help of execl. I do this in a loop:

pid_t pid = fork();
if (pid == 0) {
    while(1) {
        execl(...);
    }
}

It would seem that after the completion of the execution of execl(), the loop should restart execl(), but that was not the case. It just terminates the forked process. If I execute via system(), then everything works fine, but I need it via execl().
Why is this happening?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton Zhilin, 2016-07-26
@sitev_ru

You need to do `fork()` first, and then `execl()` inside the new process.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question