Thread: Child process status when command doesn't exist/path iis worng

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Dec 2018
    Posts
    13

    Child process status when command doesn't exist/path iis worng

    Hi, I have this program which gets two arguments as parameters and runs it in linux:

    Code:
    
     int main(int argc, char *argv[])
    {
     
        int status;
        pid_t pid;
        pid = fork();
        if(pid == 0)
           execvp(argv[1],argv+1);
        else if (pid >0) {
                /*this is the part of the code I'm missing*/
                }
        return 0;
    }
    I need to capture if the parameters passed are not a valid UX command.
    I've tried WIFEXITED and WEXISTSTATUS but they always return "1" whether it's a valid linux command or not. Is there a way to know if the linux command wwhich the child process is running doesn't exist?
    Last edited by Sergi; 05-12-2019 at 05:49 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Generated absolute path via for in doesn't exist
    By awsdert in forum Linux Programming
    Replies: 3
    Last Post: 02-06-2019, 04:31 AM
  2. create a child process that creates a child process
    By cus in forum Linux Programming
    Replies: 9
    Last Post: 01-13-2009, 02:14 PM
  3. Child process status
    By paraglidersd in forum C Programming
    Replies: 8
    Last Post: 07-24-2008, 10:51 AM
  4. get the status of the child process
    By mystic-d in forum C Programming
    Replies: 9
    Last Post: 11-17-2007, 04:59 AM
  5. Doesn't exist?
    By Llam4 in forum C# Programming
    Replies: 7
    Last Post: 04-10-2007, 12:33 PM

Tags for this Thread