execve(“/bin/sh”, 0, 0); in a pipe

后端 未结 3 740
广开言路
广开言路 2021-02-14 10:25

I have the following example program:

#include 

int
main(int argc, char ** argv){
    char buf[100];

    printf(\"Please enter your name: \");
          


        
3条回答
  •  孤城傲影
    2021-02-14 11:11

    Using execve("/bin/sh", 0, 0); is cruel and unusual punishment for the shell. It gives it no arguments or environment at all - not even its own program name, nor even such mandatory environment variables as PATH or HOME.

提交回复
热议问题