【nodejs --学习01】: node之child_process
来源:互联网 发布:php上传图片插件 编辑:程序博客网 时间:2024/06/05 02:48
child_process.fork(modulePath[, args][, options])
modulePath
String The module to run in the childargs
Array List of string argumentsoptions
Objectcwd
String Current working directory of the child processenv
Object Environment key-value pairsexecPath
String Executable used to create the child processexecArgv
Array List of string arguments passed to the executable (Default: process.execArgv)silent
Boolean If true, stdin, stdout, and stderr of the child will be piped to the parent, otherwise they will be inherited from the parent, see the “pipe” and “inherit” options for spawn()’s stdio for more details (default is false)uid
Number Sets the user identity of the process. (See setuid(2).)gid
Number Sets the group identity of the process. (See setgid(2).)
child_process.fork() 能够让你创建一个子进程,并且可以和父进程进行通信。
例子: main.js
var cp = require('child_process');var n = cp.fork(__dirname + '/sub.js');n.on('message', function(m) { console.log('PARENT got message:', m);});n.send({ hello: 'child' });
sub.js
process.on('message', function(m) { console.log('CHILD got message:', m);});process.send({ hello: 'father' });
然后通过node main.js
运行main.js,得到的结果如下
CHILD got message: { hello: 'child' }PARENT got message: { hello: 'father' }
child_process.send(message[, sendHandle])
message
ObjectsendHandle Handle
object
例子同上
阅读全文
0 0
- 【nodejs --学习01】: node之child_process
- node child_process模块学习笔记
- nodejs之child_process子进程模块
- nodejs学习--子进程 child_process模块的基本介绍
- Node.js学习笔记(6、child_process模块)
- Node(18) child_process
- Node.js子进程child_process
- node.js学习认识五:Nodejs初阶之express
- 从Node.js的child_process模块来学习父子进程之间的通信
- 【Node.js】Nodejs学习路线图
- nodejs 开发服务端 child_process 调试方法(1)
- nodejs之node-modules理解
- Node.js 使用 child_process 实现多进程
- Node.js进程通信模块child_process
- Node.js进程通信模块child_process
- Node.js进程通信模块child_process
- Node.js 使用 child_process 实现多进程
- 学习NodeJS第一天:node.js引言
- js数据操作(es6)
- 约瑟夫问题的解决
- SSM环境下普通工具类中调用@Autowired注入的service
- Dubbo服务集群容错配置
- java 时间戳 转 昨天前天 几小时前 刚刚
- 【nodejs --学习01】: node之child_process
- 运行PLSLAM时,遇到Eigen对齐问题
- <一>Linux文件权限与属性详解--一般权限
- laravel之redis
- node学习笔记(一)
- eclipse安装lombok插件
- android Recyclerview实现类似朋友圈点击添加图片的view
- 安卓学习
- 注解收集