445 Commits

Author SHA1 Message Date
isaacs
b3cf3f35fc Report errors properly from --eval and stdin 2012-07-30 08:21:39 -07:00
Jonas Westerlund
a9b0bcfafe Assign to property of global, instead of implicit global variable
Fixes crash in strict mode.
2012-07-06 19:28:35 -07:00
isaacs
441e792849 stdin.pipe: Replace forgotten opts member 2012-06-21 19:36:17 -07:00
isaacs
5ec056633f Fix #3503: stdin: resume() on pipe(dest) 2012-06-21 16:16:30 -07:00
isaacs
5b39929d47 Add --no-deprecation and --trace-deprecation flags 2012-06-21 12:05:33 -07:00
Andreas Madsen
6d70a4ae16 node: change the constructor name of process from EventEmitter to process 2012-06-17 13:14:11 -07:00
Bert Belder
10f85fadfe Fix child_process.kill oddities
* 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
2012-06-12 23:30:56 +02:00
Fedor Indutny
af98fc9d5f child_process: new stdio API for .spawn() method 2012-06-01 20:52:13 +04:00
Andreas Madsen
81a4edcf6a cluster: remove NODE_UNIQUE_ID from env on startup
In case a worker would spawn a new subprocess with process.env, NODE_UNIQUE_ID
would have been a part of the env. Making the new subprocess believe it is a
worker, this would result in some confusion if the subprocess where to listen to
a port, since the server handle request would then be relayed to the worker.

This patch removes the NODE_UNIQUE_ID flag from process.env on startup so any
subprocess spawned by a worker is a normal process with no cluster stuff.
2012-05-21 23:27:44 +02:00
isaacs
5164ae3838 Merge remote-tracking branch 'ry/v0.6' into v0.6-merge
Conflicts:
	ChangeLog
	deps/uv/include/uv-private/uv-unix.h
	deps/uv/src/unix/core.c
	deps/uv/src/unix/sunos.c
	deps/v8/src/runtime.cc
	doc/api/crypto.markdown
	lib/http.js
	src/node_version.h
	test/gc/test-http-client-timeout.js
	wscript
2012-05-15 11:37:34 -07:00
Ben Noordhuis
bd907174e8 node: delete NODE_CHANNEL_FD from env
Prevents accidental inheritance by child processes. If the child process is a
node process, it would try to set up a channel with the parent and consequently
never quit because the channel kept the event loop alive.

Fixes #3240.
2012-05-14 07:19:11 +02:00
isaacs
07be9fc3a6 Merge remote-tracking branch 'ry/v0.6' into v0.6-merge
Conflicts:
	Makefile
	lib/zlib.js
	src/node.cc
	src/node.js
2012-05-09 15:12:13 -07:00
Felix Geisendörfer
814033365b Fix process.nextTick throw call sites
This patch now reports the proper throw call site for exceptions
triggered within process.nextTick. So instead of this:

node.js:201
        throw e; // process.nextTick error, or 'error' event on first tick
              ^

You will now see:

mydir/myscript.js:15
  throw new Error('My Error');
          ^

From my testing this patch causes no performance regressions, but does
greatly simplify processing the nextTickQueue.
2012-05-09 11:54:43 -07:00
Nathan Rajlich
b894521bd2 process: ensure that "exit" doesn't get emitted twice on a natural exit
Fixes "test/simple/test-process-exit.js".
2012-05-01 14:09:31 -07:00
Nathan Rajlich
98b4596a46 process: lint 2012-04-25 20:10:50 -07:00
Nathan Rajlich
0b5235e68c process: make --eval and reading scripts from stdin act the same
Reusing the same logic for both places for the behavior is consistent.

For example:

  $ ./node -p -e "'Hello World'"
  Hello World

  $ echo "'Hello World'" | ./node -p
  Hello World
2012-04-24 11:30:14 -07:00
isaacs
10ce3d129d Domain hooks in ReqWrap<T> and MakeCallback 2012-04-17 13:14:55 -07:00
isaacs
963459d736 Domain feature
This is a squashed commit of the main work done on the domains-wip branch.

The original commit messages are preserved for posterity:

* Implicitly add EventEmitters to active domain
* Implicitly add timers to active domain
* domain: add members, remove ctor cb
* Don't hijack bound callbacks for Domain error events
* Add dispose method
* Add domain.remove(ee) method
* A test of multiple domains in process at once
* Put the active domain on the process object
* Only intercept error arg if explicitly requested
* Typo
* Don't auto-add new domains to the current domain

    While an automatic parent/child relationship is sort of neat,
    and leads to some nice error-bubbling characteristics, it also
    results in keeping a reference to every EE and timer created,
    unless domains are explicitly disposed of.

* Explicitly adding one domain to another is still fine, of course.
* Don't allow circular domain->domain memberships
* Disposing of a domain removes it from its parent
* Domain disposal turns functions into no-ops
* More documentation of domains
* More thorough dispose() semantics
* An example using domains in an HTTP server
* Don't handle errors on a disposed domain
* Need to push, even if the same domain is entered multiple times
* Array.push is too slow for the EE Ctor
* lint domain
* domain: docs
* Also call abort and destroySoon to clean up event emitters
* domain: Wrap destroy methods in a try/catch
* Attach tick callbacks to active domain
* domain: Only implicitly bind timers, not explicitly
* domain: Don't fire timers when disposed.
* domain: Simplify naming so that MakeCallback works on Timers
* Add setInterval and nextTick to domain test
* domain: Make stack private
2012-04-17 13:14:55 -07:00
isaacs
8a15147bc5 Reapply "debug: Wait 50ms before running the main module"
This reapplies commit c781f17742170f2e127f9ee6652c56b406c30586
This reverts commit 00224771e32e4d051e5ea33b7e854f0031359912
2012-03-28 19:41:29 -07:00
Nathan Rajlich
208b230744 repl: add a 'useColors' option to the repl
This should only be minimally used, since the `terminal` value will usually be
what you are expecting. This option is specifically for the case where `terminal`
is false, but you still want colors to be output (or vice-versa).
2012-03-27 18:00:59 -07:00
Fedor Indutny
00224771e3 Revert "debug: Wait 50ms before running the main module"
This reverts commit c781f17742170f2e127f9ee6652c56b406c30586.
2012-03-28 01:40:45 +07:00
Nathan Rajlich
698e795a5f repl: fix 'terminal' mode autodetection on global repls
Fixes test/simple/test-force-repl.js
2012-03-26 19:06:58 -07:00
Nathan Rajlich
aad12d0b26 readline: migrate ansi/vt100 logic from tty to readline
The overall goal here is to make readline more interoperable with other node
Streams like say a net.Socket instance, in "terminal" mode.

See #2922 for all the details.
Closes #2922.
2012-03-26 15:21:25 -07:00
Nathan Rajlich
feaa8a41c7 cmd: add a -i / --interactive flag to force the REPL
This is the only way to spawn a node child process in REPL mode, and will
also be needed to be able to use the REPL in MinTTY.
2012-03-21 00:05:25 -07:00
isaacs
c781f17742 debug: Wait 50ms before running the main module 2012-03-20 19:46:36 -07:00
Nathan Rajlich
11d8823791 process: add process.config
This is the JS representation of the `config.gypi` file that was used when
compiling node. With this information, you can tell whether the current node
binary has shared or static dependencies, or any other configuration options
that may have been used.
2012-03-15 17:15:18 -07:00
Nathan Rajlich
f9da776b33 process: listen for the "exit" even on the main repl 2012-03-13 19:58:53 +01:00
Maciej Małecki
27a937bcf8 Revert "startup: use path.resolve instead of path.join(cwd, ...)"
This reverts commit b0c15412270f32e00c268c578f07a1ed032323f5.

Reverted commit introduced a regression causing `process.argv[0]` to be
invalid in node processes spawned from `PATH` (without explicit path to
executable file - for example when using global node installation).

Instead of finding a correct path to the executable, `process.cwd()`
would be prepended to `process.argv[0]`.
2012-02-23 20:23:26 -08:00
isaacs
634b4de2c8 Pause process.stdin in stdin getter
Otherwise, it'll be ref'ed, and keep the process hanging.
2012-02-21 15:31:50 -08:00
isaacs
27d8b059fa Pause process.stdin in stdin getter
Otherwise, it'll be ref'ed, and keep the process hanging.
2012-02-21 15:26:35 -08:00
Maciej Małecki
b0c1541227 startup: use path.resolve instead of path.join(cwd, ...) 2012-02-20 16:04:44 +01:00
Maciej Małecki
1109c8fc4e startup: move EventEmitter closer to the lookup
This makes startup faster by ~0.2 ms on my computer.
2012-02-20 16:04:44 +01:00
Maciej Małecki
c3a9733ac1 startup: use .hasOwnProperty instead of in
Benchmarks show that `.hasOwnProperty` is faster than `in` in V8. It
makes startup ~0.5 ms faster on my computer.
2012-02-20 16:04:44 +01:00
Maciej Małecki
3bc3af0276 process: remove old notices about removed methods
These methods were removed a long time ago. Keeping these notices here
makes no sense anymore.

Also, removing this part of code slightly speeds up the startup.
2012-02-15 19:45:33 -08:00
Ben Noordhuis
74a8215a86 Revert support for isolates.
It was decided that the performance benefits that isolates offer (faster spin-up
times for worker processes, faster inter-worker communication, possibly a lower
memory footprint) are not actual bottlenecks for most people and do not outweigh
the potential stability issues and intrusive changes to the code base that
first-class support for isolates requires.

Hence, this commit backs out all isolates-related changes.

Good bye, isolates. We hardly knew ye.
2012-02-06 15:44:42 +01:00
isaacs
bd21038078 Merge remote-tracking branch 'ry/master' into merge-v0.6 2012-01-31 18:22:10 -08:00
isaacs
18d179c2d8 Merge remote-tracking branch 'ry/v0.6' into master
Conflicts:
	ChangeLog
	deps/uv/src/unix/udp.c
	deps/uv/src/win/fs.c
	deps/uv/src/win/udp.c
	deps/uv/test/test-fs.c
	doc/index.html
	doc/logos/index.html
	doc/template.html
	src/node_version.h
2012-01-31 18:18:00 -08:00
Igor Zinkovsky
db3c4efd1d support for sharing streams accross isolates 2012-01-31 17:45:50 -08:00
Brandon Benvie
52bd0f93bb core: make .deprecate() warn only once 2012-01-30 14:10:18 +01:00
Brandon Benvie
5403a8ce4c core: add NativeModule.prototype.deprecate
Formalize and cleanup handling of deprecated core methods.
2012-01-30 00:27:07 +01:00
Brandon Benvie
e3c0c86b28 Change removed process methods to be non-enumerable. 2012-01-29 22:17:31 +01:00
isaacs
ff0f0aeb40 Fix #2507 Raise errors less agressively when destroying stdio streams
Also, if an error is already provided, then raise the provided
error, rather than throwing it with a less helpful 'stdout cannot
be closed' message.

This is important for properly handling EPIPEs.
2012-01-26 17:55:44 -08:00
Igor Zinkovsky
de78922b12 ref isolate loop 2012-01-20 18:03:05 -08:00
Ben Noordhuis
42281124d4 child_process: add isolates support
Passing an options object with {thread:true} to .fork() or .spawn() will run the
target script in a thread instead of a separate process.
2012-01-06 00:47:14 +01:00
Andreas Madsen
5f08c3cfa1 cluster improvements: Worker class and isolate internal messages
Fixes #2388
2012-01-04 18:30:19 -08:00
Ben Noordhuis
23bb5986d4 Remove unused variable.
The file descriptor arg to child_process._forkChild() is not used any more.
Remove it, avoids future confusion.
2011-12-06 22:02:26 +01:00
Ben Noordhuis
36815e4179 process: fix stack overflow when recursively calling process.exit() 2011-12-05 22:43:27 +01:00
Ben Noordhuis
3d22dbf27b cli: add -p switch, print result of --eval 2011-12-01 18:02:15 +01:00
Igor Zinkovsky
13324bf844 throw from stdout.end and stderr.end 2011-11-10 14:51:16 -08:00
Igor Zinkovsky
f84d86b660 make stdout stream non-destroyable 2011-11-09 15:04:44 -08:00