Граф коммитов

198 Коммитов

Автор SHA1 Сообщение Дата
Bartosz Sosnowski b90f3da9de
child_process, win: fix shell spawn with AutoRun
Under Windows system can be configured to execute a specific command
each time a shell is spawned. Under some conditions this breaks the
way node handles shell scripts under windows.
This commit adds /d switch to spawn and spawnSync which disables this
AutoRun functionality.

Fixes: https://github.com/nodejs/node-v0.x-archive/issues/25458
PR-URL: https://github.com/nodejs/node/pull/8063
Reviewed-By: João Reis <reis@janeasystems.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Josh Gavant <josh.gavant@outlook.com>
Reviewed-By: Rod Vagg <rod@vagg.org>
2016-09-09 20:51:43 +02:00
Pat Pannuto 99f45b2476
child_process: control argv0 for spawned processes
In some cases it useful to control the value of `argv[0]`, c.f.
 - https://github.com/andrewffff/child_process_with_argv0
 - https://github.com/andrep/argv0

This patch adds explicit support for setting the value of `argv[0]`
when spawning a process.

PR-URL: https://github.com/nodejs/node/pull/7696
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
2016-08-08 16:35:43 +02:00
cjihrig ff3ce11894 child_process: support stdio option in fork()
This commit allows child_process.fork() to pass stdio options
to spawn(). This allows fork() to more easily take advantage of
additional stdio channels.

Refs: https://github.com/nodejs/node-v0.x-archive/issues/5727
PR-URL: https://github.com/nodejs/node/pull/7811
Reviewed-By: Myles Borins <myles.borins@gmail.com>
Reviewed-By: Minwoo Jung <jmwsoft@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2016-07-22 11:57:01 -04:00
Robert Chiras 765de1ae11 child_process: Check stderr before accessing it
If something bad happens in spawnSync, stderr might be null. Therefore,
we have to check it before using it, so we won't mask the actual
exception.

PR-URL: https://github.com/nodejs/node/pull/6877
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Robert Jefe Lindstädt <robert.lindstaedt@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
2016-07-19 13:27:30 +02:00
Chuck Langford 99cfd53097 test: test execFile/fork arg validation
Fixes: https://github.com/nodejs/node/issues/2681
Refs: https://github.com/nodejs/node/pull/4508
PR-URL: https://github.com/nodejs/node/pull/7399
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: James M Snell <jasnell@gmail.com>
2016-06-30 16:14:55 -07:00
Rich Trott 0548e5d12a child_process: add fork/execFile arg validation
Validate fork/execFile arguments.

Fixes: https://github.com/nodejs/node/issues/2681
Refs: https://github.com/nodejs/node/pull/4508
PR-URL: https://github.com/nodejs/node/pull/7399
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: James M Snell <jasnell@gmail.com>
2016-06-30 16:14:27 -07:00
Rich Trott 0268fd0a9f child_process: preserve argument type
A previous fix for a `maxBuffer` bug resulted in a change to the
argument type for the `data` event on `child.stdin` and `child.stdout`
when using `child_process.exec()`.

This fixes the `maxBuffer` bug in a way that does not have that side
effect.

PR-URL: https://github.com/nodejs/node/pull/7391
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Jackson Tian <shyvo1987@gmail.com>
Fixes: https://github.com/nodejs/node/issues/7342
Refs: https://github.com/nodejs/node/issues/1901
2016-06-30 16:04:54 -07:00
Rich Trott 8da541bf5f Revert "child_process: measure buffer length in bytes"
This reverts commit c9a5990a76.

PR-URL: https://github.com/nodejs/node/pull/7391
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Jackson Tian <shyvo1987@gmail.com>
2016-06-30 16:03:53 -07:00
Rich Trott c9a5990a76 child_process: measure buffer length in bytes
This change fixes a known issue where `maxBuffer` limits by characters
rather than bytes. Benchmark added to confirm no performance regression
occurs with this change.

PR-URL: https://github.com/nodejs/node/pull/6764
Fixes: https://github.com/nodejs/node/issues/1901
Reviewed-By: Brian White <mscdex@mscdex.net>
2016-05-25 10:57:59 -07:00
cjihrig dc76afffb6 child_process: allow buffer encoding in spawnSync
When the 'buffer' encoding is passed to spawnSync(), an exception
is thrown in Buffer's toString() method because 'buffer' is not
a valid encoding there. This commit special cases the 'buffer'
encoding.

Fixes: https://github.com/nodejs/node/issues/6930
PR-URL: https://github.com/nodejs/node/pull/6939
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2016-05-24 09:59:11 -04:00
James M Snell dcccbfdc79 src: refactor require('constants')
The require('constants') module is currently undocumented and mashes
together unrelated constants. This refactors the require('constants')
in favor of distinct os.constants, fs.constants, and crypto.constants
that are specific to the modules for which they are relevant. The
next step is to document those within the specific modules.

PR-URL: https://github.com/nodejs/node/pull/6534
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Robert Lindstaedt <robert.lindstaedt@gmail.com>
2016-05-17 11:05:18 -07:00
Ben Noordhuis f4f6c6e815 child_process: use /system/bin/sh on android
`/bin/sh` does not exist on Android but `/system/bin/sh` does.

PR-URL: https://github.com/nodejs/node/pull/6745
Refs: https://github.com/nodejs/node/pull/6733
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Myles Borins <myles.borins@gmail.com>
2016-05-14 12:04:36 +02:00
Rich Trott 31600735f4 lib,test,tools: alignment on variable assignments
Correct alignment on variable assignments that span multiple lines in
preparation for lint rule to enforce such alignment.

PR-URL: https://github.com/nodejs/node/pull/6242
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Johan Bergström <bugs@bergstroem.nu>
Reviewed-By: James M Snell <jasnell@gmail.com>
2016-04-18 17:19:11 -07:00
James M Snell 85ab4a5f12 buffer: add .from(), .alloc() and .allocUnsafe()
Several changes:

* Soft-Deprecate Buffer() constructors
* Add `Buffer.from()`, `Buffer.alloc()`, and `Buffer.allocUnsafe()`
* Add `--zero-fill-buffers` command line option
* Add byteOffset and length to `new Buffer(arrayBuffer)` constructor
* buffer.fill('') previously had no effect, now zero-fills
* Update the docs

PR-URL: https://github.com/nodejs/node/pull/4682
Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com>
Reviewed-By: Stephen Belanger <admin@stephenbelanger.com>
2016-03-16 08:34:02 -07:00
cjihrig c3bb4b1aa5 child_process: add shell option to spawn()
This commit adds a shell option, to spawn() and spawnSync(). This
option allows child processes to be spawned with or without a
shell. The option also allows a custom shell to be defined, for
compatibility with exec()'s shell option.

Fixes: https://github.com/nodejs/node/issues/1009
PR-URL: https://github.com/nodejs/node/pull/4598
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: James M Snell <jasnell@gmail.com>
2016-01-26 19:40:43 -05:00
cjihrig 7b355c5bb3 child_process: add safety checks on stdio access
When a child process is spawned, there is no guarantee that stdout
and stderr will be created successfully. This commit adds checks
before attempting to access the streams.

PR-URL: https://github.com/nodejs/node/pull/3799
Reviewed-By: Brian White <mscdex@mscdex.net>
Reviewed-By: Evan Lucas <evanlucas@me.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2015-11-12 17:52:09 -08:00
micnic 20285ad177 lib: Consistent error messages in all modules
This commit fixes some error messages that are not consistent with
some general rules which most of the error messages follow.

PR-URL: https://github.com/nodejs/node/pull/3374
Reviewed-By: Roman Reiss <me@silverwind.io>
2015-11-09 20:08:36 +01:00
Ben Noordhuis 57bce60da3 child_process: don't fork bomb ourselves from -e
Remove the `-e` argument from process.execArgv in child_process.fork()
to keep `node -e 'require("child_process").fork("empty.js")'` from
spawning itself recursively.

Fixes: https://github.com/nodejs/node/issues/3574
PR-URL: https://github.com/nodejs/node/pull/3575
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2015-10-29 01:31:54 +01:00
James M Snell 32037b78a2 child_process: check execFile and fork args
Port of joyent/node commits:

 * e17c5a72b2
 * 70dafa7b62

Pull over test-child-process-spawn-typeerror.js from v0.12, replacing
the existing test in master. The new test includes a broader set of
tests on the various arg choices and throws.

Reviewed-By: trevnorris - Trevor Norris <trevnorris@nodejs.org>
Reviewed-By: cjihrig - Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: thefourtheye - Sakthipriyan Vairamani
PR-URL: https://github.com/nodejs/node/pull/2667
Fixes: https://github.com/nodejs/node/issues/2515
2015-09-06 21:38:00 +10:00
Ben Noordhuis 607aa3ac82 child_process: add callback parameter to .send()
Add an optional callback parameter to `ChildProcess.prototype.send()`
that is invoked when the message has been sent.

Juggle the control channel's reference count so that in-flight messages
keep the event loop (and therefore the process) alive until they have
been sent.

`ChildProcess.prototype.send()` and `process.send()` used to operate
synchronously but became asynchronous in commit libuv/libuv@393c1c5
("unix: set non-block mode in uv_{pipe,tcp,udp}_open"), which landed
in io.js in commit 07bd05b ("deps: update libuv to 1.2.1").

Fixes: https://github.com/nodejs/node/issues/760
PR-URL: https://github.com/nodejs/node/pull/2620
Reviewed-By: trevnorris - Trevor Norris <trev.norris@gmail.com>
Reviewed-By: jasnell - James M Snell <jasnell@gmail.com>
2015-09-06 21:37:58 +10:00
Roman Reiss 5acad6b163 child_process: fix arguments comments
Fixes the arguments comments for execFileSync and other related minor
inconsistencies in commented arguments in the same file.

PR-URL: https://github.com/nodejs/io.js/pull/2161
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2015-07-12 01:16:31 +02:00
Sakthipriyan Vairamani 9cd44bb2b6 util: prepend '(node) ' to deprecation messages
Changes included in this commit are

   1. Making the deprecation messages consistent. The messages will be in
      the following format

           x is deprecated. Use y instead.

      If there is no alternative for `x`, then the ` Use y instead.` part
      will not be there in the message.

   2. All the internal deprecation messages are printed with the prefix
      `(node) `, except when the `--trace-deprecation` flag is set.

Fixes: https://github.com/nodejs/io.js/issues/1883
PR-URL: https://github.com/nodejs/io.js/pull/1892
Reviewed-By: Roman Reiss <me@silverwind.io>
2015-07-03 16:32:29 +02:00
Roman Reiss b5b8ff117c lib: don't use global Buffer
Port of https://github.com/joyent/node/pull/8603

The race condition present in the original PR didn't occur, so no
workaround was needed.

PR-URL: https://github.com/nodejs/io.js/pull/1794
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
2015-06-11 20:24:44 +02:00
Evan Lucas a77c330c32 child_process: expose ChildProcess constructor
Creates two new internal modules (child_process and socket_list) for
better readability.

Exposes the ChildProcess constructor from the child_process module so
one can now `require(‘child_process’).ChildProcess`

Fixes: https://github.com/nodejs/io.js/issues/1751
PR-URL: https://github.com/nodejs/io.js/pull/1760
Reviewed-By: Chris Dickinson <christopher.s.dickinson@gmail.com>
2015-05-28 09:38:29 -05:00
Yosuke Furukawa 19ffb5cf1c lib: fix eslint styles
PR-URL: https://github.com/iojs/io.js/pull/1539
Fixes: https://github.com/iojs/io.js/issues/1253
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
Reviewed-By: Roman Reiss <me@silverwind.io>
Reviewed-By: Chris Dickinson <christopher.s.dickinson@gmail.com>
Reviewed-By: Johan Bergström <bugs@bergstroem.nu>
Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com>
2015-05-09 12:10:02 +09:00
Trevor Norris 10e31ba56c node: allow multiple arguments passed to nextTick
PR-URL: https://github.com/iojs/io.js/pull/1077
Reviewed-by: Colin Ihrig <cjihrig@gmail.com>
2015-04-15 17:02:21 -06:00
Brendan Ashworth 1219e7466c lib: reduce process.binding() calls
This commit better handles calls to process.binding() in lib/ by
no longer lazy loading the bindings (the load times themselves are
rather miniscule compared to the load time of V8) and never reloading
the bindings (which is 172 times slower than referencing a variable with
the same value).

PR-URL: https://github.com/iojs/io.js/pull/1367
Reviewed-By: Brian White <mscdex@mscdex.net>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2015-04-09 10:51:19 -07:00
Mayhem 1832743e18 lib: add missing `new` for errors lib/*.js
Not including `new` adds a useless frame and removes a potentially
useful frame.

PR-URL: https://github.com/iojs/io.js/pull/1246
Reviewed-By: Petka Antonov <petka_antonov@hotmail.com>
Reviewed-By: Roman Reiss <me@silverwind.io>
Reviewed-By: Brendan Ashworth <brendan.ashworth@me.com>
2015-03-24 12:42:15 -07:00
Zach Bruggeman 9a8f18613d child_process: add debug and error details
This commit adds debug() calls to spawn() and spawnSync(), and
attaches additional information to Error objects.

Fixes: https://github.com/iojs/io.js/issues/720
PR-URL: https://github.com/iojs/io.js/pull/721
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
2015-02-05 12:58:15 -05:00
cjihrig 6ac8bdc0ab lib: reduce util.is*() usage
Many of the util.is*() methods used to check data types
simply compare against a single value or the result of
typeof. This commit replaces calls to these methods with
equivalent checks. This commit does not touch calls to the
more complex methods (isRegExp(), isDate(), etc.).

Fixes: https://github.com/iojs/io.js/issues/607
PR-URL: https://github.com/iojs/io.js/pull/647
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2015-01-31 23:47:29 -05:00
cjihrig 785481149d child_process: clone spawn options argument
spawnSync() modifies the options argument. This commit makes
a copy of options before any modifications occur.

Fixes: https://github.com/iojs/io.js/issues/576
PR-URL: https://github.com/iojs/io.js/pull/579
Reviewed-By: Bert Belder <bertbelder@gmail.com>
2015-01-26 11:59:30 -05:00
Vladimir Kurchatkin 301a968a40 child_process: remove redundant condition
There is no need to check `flowing` since `resume` does
nothing when `flowing` is already true.

PR-URL: https://github.com/iojs/io.js/pull/511
Reviewed-By: Chris Dickinson <christopher.s.dickinson@gmail.com>
2015-01-25 00:53:04 +03:00
cjihrig 804e7aa9ab lib: use const to define constants
This commit replaces a number of var statements throughout
the lib code with const statements.

PR-URL: https://github.com/iojs/io.js/pull/541
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2015-01-21 16:21:31 -05:00
isaacs 3e1b1dd4a9 Remove excessive copyright/license boilerplate
The copyright and license notice is already in the LICENSE file.  There
is no justifiable reason to also require that it be included in every
file, since the individual files are not individually distributed except
as part of the entire package.
2015-01-12 15:30:28 -08:00
Juanjo ea945bf068 lib,src: fix spawnSync ignoring its 'env' option
PR-URL: https://github.com/joyent/node/pull/8546
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2014-12-09 18:41:30 +01:00
Trevor Norris 819690fd98 src: all wraps now use actual FunctionTemplate
Instead of simply creating a new v8::Object to contain the connection
information, instantiate a new instance of a FunctionTemplate. This will
allow future improvements for debugging and performance probes.

Additionally, the "provider" argument in the ReqWrap constructor is no
longer optional.

PR-URL: https://github.com/joyent/node/pull/8110
Signed-off-by: Trevor Norris <trev.norris@gmail.com>
Reviewed-by: Fedor Indutny <fedor@indutny.com>
Reviewed-by: Alexis Campailla <alexis@janeasystems.com>
Reviewed-by: Julien Gilli <julien.gilli@joyent.com>
2014-12-09 17:57:15 +01:00
Ben Noordhuis 21130c7d6f lib: turn on strict mode
Turn on strict mode for the files in the lib/ directory.  It helps
catch bugs and can have a positive effect on performance.

PR-URL: https://github.com/node-forward/node/pull/64
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Fedor Indutny <fedor@indutny.com>
2014-11-22 17:23:30 +01:00
cjihrig 9d95774722 child_process: improve spawn() argument handling
Add stricter argument type checking to normalizeSpawnArguments().

Removes a number of extraneous checks in spawn().

Fix regression in handling of the optional args argument.

Add more thorough testing of spawn() arguments.

Reviewed-by: Trevor Norris <trev.norris@gmail.com>
2014-09-25 15:13:14 -07:00
Trevor Norris 9b8837b355 src: be more intelligent about use of "arguments"
Use 'use strict' when there are named arguments and the arguments object
is passed to apply(). Also pass named arguments to call() when the named
argument is modified by the function.

Suggested in
https://github.com/joyent/node/pull/8302#issuecomment-54331801

Confirmed in
https://github.com/joyent/node/pull/8302#issuecomment-54364818

Signed-off-by: Trevor Norris <trev.norris@gmail.com>
2014-09-03 14:24:50 -07:00
cjihrig ea89fdfec4 child_process: do not access stderr when stdio set to 'ignore'
Currently, checkExecSyncError() attempts to access the contents
of stderr. When stdio is set to 'ignore', this causes a crash.
This commit adds a check on the access of stderr. Closes #7966.

Signed-off-by: Fedor Indutny <fedor@indutny.com>
2014-07-23 23:39:28 +04:00
Ryan Graham 245469587c lib: noisy deprecation of child_process customFds
Use a util.deprecate wrapper to issue warnings like any other
deprecated API. The option has been marked as deprecated in the docs
since v0.5.11.

Signed-off-by: Fedor Indutny <fedor@indutny.com>
2014-07-10 15:07:07 +03:00
Fedor Indutny ae1e325e8a child_process: accept uid/gid everywhere
Accept uid/gid option in every execute/spawn call (including
cluster.fork). Add documentation where needed.

fix #7881

Signed-off-by: Trevor Norris <trev.norris@gmail.com>
2014-07-02 13:01:07 -07:00
Charles be8114e5c5 child_process: don't throw on EAGAIN
Signed-off-by: Fedor Indutny <fedor@indutny.com>
2014-06-24 08:45:29 +04:00
Ed Morley c08da463ad child_process: use full path for cmd.exe on Win32
Currently child_process.exec() assumes that cmd.exe is on the PATH,
and fails with a spawn ENOENT error if it is not.

The Windows 'comspec' environment variable contains the full filepath
to the default command interpreter, eg "C:\Windows\System32\cmd.exe".
Should it not be set, we fall-back to using 'cmd.exe' from PATH, as
before.

Signed-off-by: Fedor Indutny <fedor@indutny.com>
2014-06-24 08:44:11 +04:00
Brian White 03e9f84933 lib: remove unused variables
Signed-off-by: Fedor Indutny <fedor@indutny.com>
2014-06-11 20:41:12 -07:00
Fedor Indutny 9920ae67b5 Merge branch 'v0.10'
Conflicts:
	ChangeLog
	lib/events.js
	lib/tls.js
	src/node_constants.cc
	src/node_crypto.cc
	src/node_crypto.h
	src/node_version.h
2014-06-05 07:28:39 -07:00
Ben Noordhuis a367f62adf child_process: don't throw on EMFILE/ENFILE
EMFILE and ENFILE mean 'out of file descriptors'.  It's a run-time error
and as such should emit an error on the child process object, not throw
an exception.

Fixes #7453.

Signed-off-by: Timothy J Fontaine <tjfontaine@gmail.com>
2014-05-22 12:49:59 -07:00
Ryan Cole f09b02786f child_process: add path to spawn ENOENT Error
Add a file property to the ENOENT Error returned from ChildProcess's
spawn function.

Signed-off-by: Timothy J Fontaine <tjfontaine@gmail.com>
2014-05-22 07:26:15 -07:00
Greg Sabia Tucker 7bd08c5062 child_process: do not set args before throwing
No point in setting args and options if TypeError
is being thrown.

fix #7456

Signed-off-by: Fedor Indutny <fedor@indutny.com>
2014-05-16 01:31:59 +04:00
Greg Sabia Tucker 92875501d2 child_process: spawn() does not throw TypeError
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>
2014-05-13 12:25:00 +04:00