码迷,mamicode.com
首页 > 其他好文 > 详细

execve使用

时间:2019-11-05 16:45:41      阅读:152      评论:0      收藏:0      [点我收藏+]

标签:not   could not   exe   wait   僵尸进程   char   roc   process   filename   

注意必须使用waitpid,否则会出现rm的僵尸进程。

DeleteCvsFile(const char *csvfilename)

{
int ac = 0;
char *argv[10];
char *envp[10];
argv[ac++] = "-rf";
argv[ac++] = csvfilename;
argv[ac] = NULL;
envp[0] = NULL;

pid_t pid;
if ((pid = fork_process()) == 0)
{
if (execve("/bin/rm", argv, envp) < 0)
{
ereport(LOG,
(errmsg("could not execute server process \"%s\".",
"/bin/rm")));
exit(1);
}
}
int ret = waitpid(pid, NULL, 0);
}

execve使用

标签:not   could not   exe   wait   僵尸进程   char   roc   process   filename   

原文地址:https://www.cnblogs.com/gelon/p/11799226.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!