简体   繁体   English

拥有std = c99时如何使用exec / kill?

[英]How can I use exec / kill while having std=c99?

When I try to use exec: 当我尝试使用exec时:

#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <stdlib.h>


int main()
{
    exec("echo `Hello World`");
    return 0;
}

I get this error: 我收到此错误:

code.c:11: error: implicit declaration of function ‘exec’
make: *** [code.o] Error 1

I have to use std=c99 and I can't add any other compiler flags. 我必须使用std = c99,并且不能添加任何其他编译器标志。 How can I use exec (or a simmilar call)? 如何使用exec(或类似电话)?

I guess the solution will be the same for kill, wouldn't it? 我想杀人的方法是一样的,不是吗?

Based on your includes, it appears like you're using a Unix of some kind. 根据您的包含,似乎您正在使用某种Unix。 There is no exec call. 没有exec调用。 There is execl , exexlp , and others with names depending on the exact types of parameters. 根据参数的确切类型,有execlexexlp和其他带有名称的文件。 Check the man page for 'exec' for details. 有关详细信息,请参见手册页中的“ exec”。

您需要#define _POSIX_C_SOURCE 200809L#define _XOPEN_SOURCE 700 ,或在编译器的命令行上使用等效的-D选项。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM