Calling exec returns errno 14 (bad address) with absolute path

前端 未结 3 1914
暖寄归人
暖寄归人 2021-01-12 16:08

in making a simple cgi server for a course. To do that in some point I have to make a fork/exec to launch the cgi handler, the problem is that the exec keep returning errno

3条回答
  •  暗喜
    暗喜 (楼主)
    2021-01-12 16:46

        execl("/home/dvd/nwebdir/simple.cgi", &ctx->uri[1], (char *)0);
    

    The last argument to execl() must be a null char *. You can usually get away with writing NULL instead of (char *)0, but it might not produce the correct result if you have #define NULL 0 and you are on a machine where sizeof(int) != sizeof(char *), such as a 64-bit system.

提交回复
热议问题