专注各种脚本编程
Baidu
加入收藏夹
本站内容有下面分类知识,欢迎您的到来^_^
shell相关:指令篇 基础篇 脚本欣赏 编程实例 shell问问 shell视频教程 技巧篇 水平测试 E文资料 vi编辑器 高级Bash脚本编程指南
其他:mysql perl c语言 oracle
当前位置:| 主页>perl>

perl进程控制函数sleep/wait/waitpid

百度收藏 QQ搜藏
函数名 sleep
调用语法 sleep (time);
解说 将程序暂停一段时间。time是停止的秒数。返回值为实际停止的秒数。
例子 sleep (5);
结果输出

函数名 wait
调用语法 procid = wait();
解说 暂停程序执行,等待子进程终止。
不需要参数,返回值为子进程ID,如果没有子进程,返回-1。
例子  
结果输出  

函数名 waitpid
调用语法 waitpid (procid, waitflag);
解说 暂停程序执行,等待特定的子进程终止。procid为等待的进程ID
例子 $procid = fork();
if ($procid == 0) {
  # this is the child process
  print ("this line is printed first\n");
  exit(0);
} else {
  # this is the parent process
  waitpid ($procid, 0);
  print ("this line is printed last\n");
}
结果输出 $ program
this line is printed first
this line is printed last
$
上一篇:perl进程终止函数die/warn/exit/kill 下一篇:perl其它控制函数caller/chroot/local/times

power by soyo123 2007-2008