summaryrefslogtreecommitdiff
path: root/lib/child_process.js
Commit message (Collapse)AuthorAgeFilesLines
* lint: fix lint issuesTrevor Norris2014-11-181-4/+2
| | | | | | Forgot to fix these before landing the patch. Fixes: e17c5a72
* child_process: check fork args is an arraySam Roberts2014-11-181-0/+2
| | | | | | | | Optional fork args should be type-checked with same behaviour as the equivalent argument to spawn. PR-URL: https://github.com/joyent/node/pull/8454 Reviewed-by: Trevor Norris <trev.norris@gmail.com>
* child_process: check execFile args is an arraySam Roberts2014-11-181-10/+20
| | | | | | | | | execFile and spawn have same API signature with respect to optional arg array and optional options object, they should have same behaviour with respect to argument validation. PR-URL: https://github.com/joyent/node/pull/8454 Reviewed-by: Trevor Norris <trev.norris@gmail.com>
* child_process: properly support optional argscjihrig2014-09-171-1/+1
| | | | | | | | Currently, a TypeError is incorrectly thrown if the second argument is an object. This commit allows the args argument to be properly omitted. Fixes: https://github.com/joyent/node/issues/6068 Reviewed-by: Trevor Norris <trev.norris@gmail.com>
* child_process: handle writeUtf8String errorFedor Indutny2014-07-121-0/+1
| | | | | | | When handling `writeUtf8String` error, return after emitting it. Otherwise a runtime failure can occur. fix #7923
* child_process: do not set args before throwingGreg Sabia Tucker2014-05-161-2/+0
| | | | | | | | | No point in setting args and options if TypeError is being thrown. fix #7456 Signed-off-by: Fedor Indutny <fedor@indutny.com>
* child_process: spawn() does not throw TypeErrorGreg Sabia Tucker2014-05-131-1/+5
| | | | | | | | | | | | Ensure TypeError is thrown, fix a bug where `env` option was assuming the option was actually an object. This case is especially bad because it then sets `env == null` instead of using `process.env`. Fix #7456 Signed-off-by: Fedor Indutny <fedor@indutny.com>
* child_process: fix deadlock when sending handlesFedor Indutny2014-04-141-1/+2
| | | | | | | | Fix possible deadlock, when handles are sent in both direction simultaneously. In such rare cases, both sides may queue their `NODE_HANDLE_ACK` replies and wait for them. fix #7465
* child_process: fix sending handle twiceFedor Indutny2014-03-051-1/+10
| | | | | | | | | | | | | | | When sending a socket to a child process via IPC pipe, `child_process.js` picks a raw UV handle from `_handle` property, sends it, and assigns `null` to the property. Sending the same socket twice was resulting in a runtime error, since we weren't handling the empty `_handle` case. In case of `null` `_handle` we should send just a plain text message as passed it was passed to `.send()` and ignore the handle, letting users handle such cases themselves instead of throwing the error at runtime. fix #5469
* child_process: fix spawn() optional argumentsSam Roberts2014-01-161-2/+10
| | | | | | | Spawn's arguments were documented to be optional, as they are for the other similar child_process APIs, but the code was missing. Result was `child_process.spawn('node', {})` errored when calling slice() on an Object, now it behaves as the documentation said it would.
* child_process: fix handle deliveryBen Noordhuis2013-05-131-2/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Commit 9352c19 ("child_process: don't emit same handle twice") trades one bug for another. Before said commit, a handle was sometimes delivered with messages it didn't belong to. The bug fix introduced another bug that needs some explaining. On UNIX systems, handles are basically file descriptors that are passed around with the sendmsg() and recvmsg() system calls, using auxiliary data (SCM_RIGHTS) as the transport. node.js and libuv depend on the fact that none of the supported systems ever emit more than one SCM_RIGHTS message from a recvmsg() syscall. That assumption is something we should probably address someday for the sake of portability but that's a separate discussion. So, SCM_RIGHTS messages are never coalesced. SCM_RIGHTS and normal messages however _are_ coalesced. That is, recvmsg() might return this: recvmsg(); // { "message-with-fd", "message", "message" } The operating system implicitly breaks pending messages along SCM_RIGHTS boundaries. Most Unices break before such messages but Linux also breaks _after_ them. When the sender looks like this: sendmsg("message"); sendmsg("message-with-fd"); sendmsg("message"); Then on most Unices the receiver sees messages arriving like this: recvmsg(); // { "message" } recvmsg(); // { "message-with-fd", "message" } The bug fix in commit 9352c19 assumes this behavior. On Linux however, those messages can also come in like this: recvmsg(); // { "message", "message-with-fd" } recvmsg(); // { "message" } In other words, it's incorrect to assume that the file descriptor is always attached to the first message. This commit makes node wise up. Fixes #5330.
* child_process: fix O(n*m) scan of cmd stringBen Noordhuis2013-04-111-8/+6
| | | | | | | | Don't scan the whole string for a "NODE_" substring, just check that the string starts with the expected prefix. This is a reprise of dbbfbe7 but this time for the child_process module.
* child_process: acknowledge sent handlesFedor Indutny2013-04-031-0/+29
| | | | | | | | Fix race-condition when multiple handles are sent and SCM_RIGHTS messages are gets merged by OS by avoiding sending multiple handles at once! fix #4885
* child_process: don't emit same handle twiceBen Noordhuis2013-03-251-0/+1
| | | | | | It's possible to read multiple messages off the parent/child channel. When that happens, make sure that recvHandle is cleared after emitting the first message so it doesn't get emitted twice.
* child_process: fix sending utf-8 to child processBen Noordhuis2013-03-251-1/+3
| | | | | | | | | | | | | In process#send() and child_process.ChildProcess#send(), use 'utf8' as the encoding instead of 'ascii' because 'ascii' mutilates non-ASCII input. Correctly handle partial character sequences by introducing a StringDecoder. Sending over UTF-8 no longer works in v0.10 because the high bit of each byte is now cleared when converting a Buffer to ASCII. See commit 96a314b for details. Fixes #4999 and #5011.
* child_process: support sending dgram socketAndreas Madsen2013-03-071-0/+21
| | | | | | child.send can send net servers and sockets. Now that we have support for dgram clusters this functionality should be extended to include dgram sockets.
* child_process: handle ENOENT correctly on WindowsScott Blomquist2013-03-051-2/+2
|
* lib, src: remove errno globalBen Noordhuis2013-02-281-7/+9
| | | | | | Remove the errno global. It's a property on the process object now. Fixes #3095.
* cluster: support datagram socketsBert Belder2013-01-281-9/+23
|
* child_process: move binding init in constructorFedor Indutny2013-01-281-0/+4
| | | | | Doing this in net.Socket constructor has much more overhead, and error is actually may happen before the construction of socket object.
* child_process: remove .track optionFedor Indutny2013-01-201-74/+8
| | | | | Since net.Server's `connection` property is deprecated now, we don't need API to track socket's state to keep `connection`s value up-to-date.
* child_process: do not keep list of sent socketsFedor Indutny2013-01-181-54/+137
| | | | | | | | | | | | | | | | | Keeping list of all sockets that were sent to child process causes memory leak and thus unacceptable (see #4587). However `server.close()` should still work properly. This commit introduces two options: * child.send(socket, { track: true }) - will send socket and track its status. You should use it when you want to receive `close` event on sent sockets. * child.send(socket) - will send socket without tracking it status. This performs much better, because of smaller number of RTT between master and child. With both of these options `server.close()` will wait for all sent sockets to get closed.
* Revert "child_process: do not keep list of sent sockets"Fedor Indutny2013-01-181-137/+54
| | | | This reverts commit db5ee0b3decace9b5d80ee535ce53183aff02909.
* child_process: do not keep list of sent socketsFedor Indutny2013-01-171-54/+137
| | | | | | | | | | | | | | | | | | Keeping list of all sockets that were sent to child process causes memory leak and thus unacceptable (see #4587). However `server.close()` should still work properly. This commit introduces two options: * child.send(socket, { track: true }) - will send socket and track its status. You should use it when you want `server.connections` to be a reliable number, and receive `close` event on sent sockets. * child.send(socket) - will send socket without tracking it status. This performs much better, because of smaller number of RTT between master and child. With both of these options `server.close()` will wait for all sent sockets to get closed.
* child_process: Pull through untouched stdio streamsisaacs2013-01-071-0/+21
| | | | | Otherwise child procs will never emit a 'close' event if you don't ever consume their streams, because they will never hit the EOF.
* child_process: don't `resume()` created socketMaciej MaƂecki2013-01-071-1/+0
| | | | | | | Calling `resume()` on a stream switches it to the old mode which causes piping stdio from a child process to fail. Fixes joyent/node#4510.
* child_process: make fork() execPath configurableBradley Meck2013-01-061-1/+3
| | | | | | | | Allows for arbitrary path to executable spawned using `fork`. This fixes some issues around running multiple versions of node with workers and allows arbitrary IPC with compatible executables. Fixes #3248.
* child_process: Remove stream.pause/resume callsisaacs2012-12-141-3/+0
| | | | Unnecessary in streams2
* child_process: don't die when disconnect event existsAndreas Madsen2012-09-221-2/+5
|
* child_process: make .fork()'d child auto-exitBen Noordhuis2012-09-221-0/+8
| | | | | | | | | A child process created with .fork() needed to call `process.exit()` explicitly because the communication channel with the parent kept the event loop alive. Fix that by only ref'ing the channel when there are 'message' event listeners. Fixes #3799.
* Merge remote-tracking branch 'origin/v0.8'Ben Noordhuis2012-09-041-1/+9
|\ | | | | | | | | | | Conflicts: deps/uv/include/uv.h src/node_crypto.cc
| * child process: fix processes with IPC channel don't emit 'close'Bert Belder2012-08-301-1/+9
| | | | | | | | | | | | | | With this patch the IPC socket is no longer available in the ChildProcess.stdio array. This shouldn't be very problematic, since this socket was effectively non-functional; it would never emit any events.
* | Merge branch 'v0.8'Bert Belder2012-08-281-1/+2
|\ \ | |/ | | | | | | | | | | Conflicts: ChangeLog deps/openssl/openssl.gyp src/node_version.h
| * windows: fix single-accept mode for shared server socketsBert Belder2012-08-281-1/+2
| |
* | child_process: emit error on exec failureBen Noordhuis2012-08-211-1/+11
| | | | | | | | | | libuv calls the exit cb with exit code == -1 when it fails to spawn the new process. Anticipate that and emit the error on the ChildProcess object.
* | Merge remote-tracking branch 'origin/v0.8'Ben Noordhuis2012-08-171-3/+4
|\ \ | |/ | | | | | | | | | | | | Conflicts: ChangeLog src/node_version.h test/message/stdin_messages.out tools/install.py
| * child_process: Fix stdout=null when stdio=['pipe']Tyler Neylon2012-08-041-3/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | Previously, a command with a short stdio array would result in the child's stdout and stderr objects set to null. For example: var c = child_process.spawn(cmd, args, {stdio: ['pipe']}); // results in c.stdout === null. The expected behavior is the above line functioning the same as this one: var c = child_process.spawn(cmd, args, {stdio: ['pipe', null, null]}); // provides correct (non-null) c.stdout; as does the above, after this fix.
* | net: fix listen() regression, revert patchesBen Noordhuis2012-08-061-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit reverts the following commits (in reverse chronological order): 74d076c errnoException must be done immediately ddb02b9 net: support Server.listen(Pipe) 085a098 cluster: do not use internal server API d138875 net: lazy listen on handler Commit d138875 introduced a backwards incompatible change that broke the simple/test-net-socket-timeout and simple/test-net-lazy-listen tests - it defers listening on the target port until the `net.Server` instance has at least one 'connection' event listener. The other patches had to be reverted in order to revert d138875. Fixes #3832.
* | cluster: do not use internal server APIAndreas Madsen2012-08-051-1/+1
| |
* | child_process: improve maxBuffer error messageTom Hughes-Croucher2012-07-291-2/+2
|/ | | | Mention what buffer (stdout, stderr) overflowed.
* child_process: add .stdin stream to forksFedor Indutny2012-06-191-1/+2
| | | | | Remove test as it doesn't make any sense after the latest stdio API changes.
* 2012.06.15, Version 0.7.11 (unstable)v0.7.11isaacs2012-06-151-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * V8: Upgrade to v3.11.10 * npm: Upgrade to 1.1.26 * doc: Improve cross-linking in API docs markdown (Ben Kelly) * Fix #3425: removeAllListeners should delete array (Reid Burke) * cluster: don't silently drop messages when the write queue gets big (Bert Belder) * Add Buffer.concat method (isaacs) * windows: make symlinks tolerant to forward slashes (Bert Belder) * build: Add node.d and node.1 to installer (isaacs) * cluster: rename worker.unqiueID to worker.id (Andreas Madsen) * Windows: Enable ETW events on Windows for existing DTrace probes. (Igor Zinkovsky) * test: bundle node-weak in test/gc so that it doesn't need to be downloaded (Nathan Rajlich) * Make many tests pass on Windows (Bert Belder) * Fix #3388 Support listening on file descriptors (isaacs) * Fix #3407 Add os.tmpDir() (isaacs) * Unbreak the snapshotted build on Windows (Bert Belder) * Clean up child_process.kill throws (Bert Belder) * crypto: make cipher/decipher accept buffer args (Ben Noordhuis)
* domain: the EventEmitter constructor is now always called in nodecoreAndreas Madsen2012-06-151-0/+6
|
* Fix child_process.kill odditiesBert Belder2012-06-121-10/+41
| | | | | | | | | | | | | | | | | | | * When the process is already dead, but the `exit` signal wasn't raised yet, the ESRCH error should be ignored. * When an invalid signal is specified, kill() should throw. * Like process.kill(), child_process.kill() now preserves a `0` signal which can be used to check the liveliness of the child process. * process.kill() and child_process.kill() will now return true if the signal was actually delivered, and false otherwise. * When an `exec`-ed process is automatically killed because a time or buffer limit is exceeded, and the kill() fails, this error should be reported through the `exec` callback. Fixes: #3409
* cluster: don't silently drop messages when the write queue gets bigBert Belder2012-06-111-6/+2
|
* Remove auto-unrefisaacs2012-06-111-4/+0
| | | | cc: @AvianFlu @AndreasMadsen
* child_process: expose UV_PROCESS_DETACHED as options.detachedCharlie McConnell2012-06-081-0/+5
|
* child_process: spawn().ref() and spawn().unref()Fedor Indutny2012-06-071-0/+10
|
* child_process: new stdio API for .spawn() methodFedor Indutny2012-06-011-78/+158
|
* child_process: hook up handle wrap to owning objectBen Noordhuis2012-05-151-0/+2
|