[NPWP笔记]perl创建进程
来源:互联网 发布:peas网络验证 编辑:程序博客网 时间:2024/06/04 19:07
根据PID判断当前运行的进程为主进程还是子进程,下面的代码在Linux平台可以正确运行。
#!/usr/bin/perl
use 5.006;
use strict;
use warnings;
print "PID = $$/n";
my $child = fork();
die "can not fork:$!" unless defined $child;
if($child > 0)
{
print "parent PID = $$,child PID = $child/n";
}
else
{
my $ppchid = getppid();
print "child pid = $$,parent pid = $ppchid/n";
}
Linux输出结果:
landopen@server01:~$ perl fork.pl
PID = 13322
parent PID = 13322,child PID = 13323
landopen@server01:~$ child pid = 13323,parent pid = 1
Windows报错如下,不支持getppid函数
PID = 1312
The getppid function is unimplemented at D:/Documents and Settings/Administrator/My Documents/fork_child.pl line 18.
The getppid function is unimplemented at D:/Documents and Settings/Administrator/My Documents/fork_child.pl line 18.
- [NPWP笔记]perl创建进程
- [NPWP笔记]使用perl读取文件
- [NPWP笔记]perl函数使用文件句柄
- [NPWP笔记]自动生成子进程服务器
- [NPWP笔记]使用perl循环读取标准输入设备
- [NPWP笔记]Develop a multi-process server with perl
- [NPWP笔记]使用多进程处理客户请求
- [NPWP笔记]多线程服务器
- [NPWP笔记]多线程客户端
- [NPWP笔记]multiplexed客户端
- [NPWP笔记]multiplexed服务器
- perl中创建多进程
- Perl笔记14、进程管理
- [NPWP笔记]从管道中读取数据
- [NPWP笔记]非阻塞文件读取
- [NPWP笔记]Write a FTP client with two-process model
- Linux进程线程学习笔记:进程创建
- Linux进程线程学习笔记:进程创建
- POJ 1141 Brackets Sequence 动态规划
- linux的常用命令
- TypeList 之 NoDuplicate
- 《Windows核心编程》读书心得——字符和字符串处理(1)
- Chapter3 Windows and Messages —— Programming Windows 笔记
- [NPWP笔记]perl创建进程
- 制作Java Applet签名验证
- MFC 中 WM_NOTIFY messages 传递过程
- 转发屠夫大牛使用未公开API ZwQueryVirtualMemory 枚举进程模块的函数例子
- 流水灯&万用板
- vs2005 无法新建 c++ Smart Device的工程解决方案
- “简单没那么容易做到”
- 获取操作系统版本字符串(转自MSDN) 附判断操作系统的代码
- sicily 1003 水题