Search code examples
cunistd.h

Can't run two times execl


If I try to executes these commands:

int main(int argc, char* argv[])
{
    execl("/bin/echo","echo","list ","of", "files:\n",NULL);
    execl("/bin/ls","ls","-al",NULL);
    return 0;
}

Only the first one gets executed, why?


Solution

  • execl REPLACES the current process - it's not a subroutine. You might try using system() instead.