【发布时间】:2019-02-20 04:03:30
【问题描述】:
我正在尝试制作一个简单的脚本来了解如何使用 PING 命令来获得乐趣(现在正在大学学习数据安全课程)。我有以下代码:
#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>
int main( void )
{
int status;
char *args[2];
args[0] = "ping 192.(hidden for privacy) -s 256 "; // first arg is the full path to the executable
args[1] = NULL; // list of args must be NULL terminated
if ( fork() == 0 )
execv( args[0], args );
else
wait( &status );
return 0;
}
【问题讨论】:
-
该函数有三 (3) 种返回:
fork()1) 0 表示在父进程中。发布的代码无法检查失败情况 -
那么您面临的问题是什么?请提及问题的位置和描述