execlp() system call error in output

后端 未结 3 388
深忆病人
深忆病人 2021-01-25 22:50

This very simple example of exec() system call. Here, I am trying to call execlp() twice. But, I am not getting excepted output. It shows output only f

3条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-25 23:16

    #include 
    #include 
    
    int main() { 
    
            int ret1,ret2;
    
            pid_t chd;
            chd=fork(); 
            if(chd==0)
            ret1 = execlp( "pwd", "pwd", (char *) 0);
            else if(chd>0)
            ret2 = execlp( "date", "date", (char *) 0);
            return 0;
    }
    

提交回复
热议问题