- #!/usr/bin/perl -w
- # wangxiaoyu#live.com
- use strict;
- defined(my $pid=fork()) or die "Fork process failured:$!\n";
- unless($pid)
- {
- # This is the child process.
- system "date";
- sleep(3);
- print ("Exit child after 3 seconds wait!\n");
- exit();
- }
- # This is the parent process.
- waitpid($pid,0);
- system "date";
- print ("exit parent!\n");
关于理解Perl的fork函数
Perl脚本父子进程示例
最新推荐文章于 2025-01-28 00:05:08 发布
本文通过一个Perl脚本示例介绍了如何使用fork创建子进程,并演示了父进程与子进程间的简单交互。子进程执行完特定任务后退出,父进程等待子进程结束并随之终止。
625

被折叠的 条评论
为什么被折叠?



