Commit Graph

34 Commits

Author SHA1 Message Date
Ben Noordhuis
837edf4c0f unix, windows: remove handle init counters
Remove the handle init counters, no one uses them.
2012-08-10 02:00:11 +02:00
Ben Noordhuis
75ba681913 unix: remove dependency on ev_child 2012-08-10 02:00:11 +02:00
Ben Noordhuis
d4737abd6d unix: remove dead code in process.c
uv_spawn() saves and restores the environ in case the child clobbers it -
which is impossible because the child process runs in a separate address space.
2012-08-08 23:20:28 +02:00
Ben Noordhuis
47f496aa65 unix: simplify stdio handling in process.c 2012-08-08 23:20:28 +02:00
Ben Noordhuis
13467a40d4 unix: retrieve execve() errors in process.c
Make the forked child process send the errno to its parent process when it
fails to spawn a new process.
2012-08-08 23:19:50 +02:00
Ben Noordhuis
bf28aa4e78 unix: drop SPAWN_WAIT_EXEC guard in process.c
Code cleanup. This "experimental" feature was always enabled anyway, might as
well remove the define guard.
2012-08-08 14:44:38 +02:00
Bert Belder
5d5688f241 unix: always set CLOEXEC flag for child process stdio FDs 2012-06-14 18:29:47 +02:00
Ben Noordhuis
ddb5f55922 unix: simplify uv__make_pipe() and uv__make_socketpair() 2012-06-11 02:47:39 +02:00
Fedor Indutny
a30e45f1d7 unix: remap fds 0-2 to /dev/null if ignore flag set 2012-06-04 16:14:21 +02:00
Fedor Indutny
f5b5127db0 change spawn() api to allow using existing streams for stdio
This commit also adds support for this api on Unix.
2012-06-01 17:32:27 +02:00
Charlie McConnell
69a923bf93 process: implement UV_PROCESS_DETACHED flag for uv_spawn 2012-06-01 02:24:05 +02:00
Fedor Indutny
c0081f0e66 unix: allow specifying FDs to be inherited by a child process
Previously the only option was to create a pipe or an ipc channel. This
patch makes it possible to inherit a handle that is already open in the
parent process. It also makes it possible to set more than just stdin,
stdout and stderr.
2012-05-29 00:05:12 +02:00
Ben Noordhuis
9efa8b3571 unix, windows: rework reference counting scheme
This commit changes how the event loop determines if it needs to stay alive.

Previously, an internal counter was increased whenever a handle got created
and decreased again when the handle was closed.

While conceptually simple, it turned out hard to work with: you often want
to keep the event loop alive only if the handle is actually doing something.
Stopped or inactive handles were a frequent source of hanging event loops.

That's why this commit changes the reference counting scheme to a model where
a handle only references the event loop when it's active. 'Active' means
different things for different handle types, e.g.:

 * timers: ticking
 * sockets: reading, writing or listening
 * processes: always active (for now, subject to change)
 * idle, check, prepare: only active when started

This commit also changes how the uv_ref() and uv_unref() functions work: they
now operate on the level of individual handles, not the whole event loop.

The Windows implementation was done by Bert Belder.
2012-05-17 07:07:53 +02:00
Bert Belder
e38755485e Unix: namespace stream handle flags 2012-05-03 01:47:13 +02:00
Ben Noordhuis
1ebe14e494 linux: fix build error with old kernel headers
O_CLOEXEC was introduced in linux 2.6.23, don't assume it's available.

Fixes #400.
2012-05-02 17:42:59 +02:00
Bert Belder
99a995a6b8 uv_spawn: support setting the child process' user and group id 2012-04-28 02:38:41 +02:00
Ben Noordhuis
5a8446c309 unix: move handle specific close logic out of core.c 2012-04-04 05:30:15 -07:00
Ben Noordhuis
685b36ba66 linux: tidy up syscall code 2012-03-31 00:19:01 +00:00
Bulat Shakirzyanov
31ff9863a1 unix: fix TARGET_OS_IPHONE conditional 2012-03-28 15:45:44 +02:00
Ben Noordhuis
4ff0898c5f unix: replace uv__close() with close()
uv__close() was deprecated a while ago. It's been an alias for close() ever
since. Remove it.
2012-03-21 02:11:18 +01:00
Ben Noordhuis
ec0eff955e Revert b3e0ad4, 149d32c, e99fdf0 and ea9baef.
Detaching doesn't work yet, the setsid() call fails and leaves the child process
attached to the parent's session.

Revert "test: Add test case for spawning detached child processes."
Revert "win: Implement options.detached for uv_spawn() for Windows."
Revert "unix: Implement options.detached for uv_spawn() for unix."
Revert "Add "detached" member to uv_process_options_t to denote whether a child
        process should spawn detached from its parent."

This reverts commit ea9baef95c.
This reverts commit e99fdf0df6.
This reverts commit 149d32cb96.
This reverts commit b3e0ad4db8.
2012-02-28 15:29:05 +01:00
Ben Noordhuis
57c5fa1af1 unix: fix build on iOS
_NSGetEnviron() doesn't exist on iOS, use plain `extern char **environ` instead.
2012-02-26 00:36:28 +01:00
Charlie McConnell
149d32cb96 unix: Implement options.detached for uv_spawn() for unix. 2012-02-24 15:15:00 +01:00
Ryan Dahl
3dd4ecb493 unix: expose uv__make_socketpair, uv__make_pipe in unix/internal.h 2011-12-29 22:37:33 -08:00
Ben Noordhuis
d5b26154f7 linux: improve kernel feature detection
Do not check for minimum kernel and glibc versions, just check that the kernel
headers export the syscall number and invoke the syscall directly. Effectively
bypasses glibc.
2011-11-17 18:05:53 +01:00
Ben Noordhuis
4794c12f58 linux: fall back to traditional syscalls if necessary
libuv uses feature checks to determine if newer syscalls like pipe2() are
available. This works fine until someone compiles libuv against kernel headers
that are newer than the actual kernel our software runs on.

Fall back to traditional (but race-y!) syscalls when the kernel reports ENOSYS
or EINVAL.
2011-11-09 15:38:51 +01:00
Igor Zinkovsky
74b49e821b uv_kill 2011-11-02 14:34:07 -07:00
Ben Noordhuis
f7f518aa7e sunos: fix uv_spawn()
SunOS does not set POLLHUP when the read end of a pipe is closed.
2011-10-10 23:59:54 +00:00
Ryan Dahl
1c72aebd78 unix: IPC stdio stream should be duplex 2011-10-07 01:41:42 -07:00
Ryan Dahl
6921d2fc07 Add argument to uv_pipe_init for IPC, unix impl 2011-10-06 10:17:07 -07:00
Erick Tryzelaar
23796d208c Fixes #76. Unify OS error reporting
As a nice fringe benefit, this also shaves a word
off of a windows TCP handle by replacing "uv_err_t
bind_error" with "int bind_error".
2011-09-27 19:05:33 -07:00
Ryan Dahl
2640aae125 unix: Reset flags for stdio fds after fork 2011-09-15 15:24:09 -07:00
Ben Noordhuis
bb0c6e6d53 unix: move linux feature detection macros to internal.h 2011-09-05 16:05:28 +02:00
Ryan Dahl
e553f96f94 unix: split out uv_spawn into src/unix/process.c 2011-08-31 11:50:08 -07:00