Commit Graph

65 Commits

Author SHA1 Message Date
Anders Johnsen 9a01a22e96 Revert "Clean up process spawning."
This reverts commits
- bbdc57ebf6
- bd25e641f2
- 5cc8fca131
- ed72caa3cd

BUG=

Review URL: https://codereview.chromium.org//1182423003.
2015-06-15 15:26:56 +02:00
Anders Johnsen bbdc57ebf6 Clean up process spawning.
Pass environment as argument to execvpe and use _exit instead of exit
(so fork/vfork can be used interchangeable).

BUG=
R=sgjesse@google.com

Review URL: https://codereview.chromium.org//1156313004.
2015-06-10 10:42:54 +02:00
ajohnsen@google.com ab6f8cc118 Make all of stdout/stderr/stdin pipes close-on-exec when spawing child processes.
BUG=
R=sgjesse@google.com

Review URL: https://codereview.chromium.org//1076093004

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@45370 260f80e4-7a28-3924-810f-c04153c831b5
2015-04-23 07:37:53 +00:00
sgjesse@google.com 9aa4805e21 Add an option for starting a detached process with stdio connected
R=lrn@google.com, kustermann@google.com
BUG=

Review URL: https://codereview.chromium.org//890633002

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@43393 260f80e4-7a28-3924-810f-c04153c831b5
2015-02-03 13:38:38 +00:00
sgjesse@google.com 042462d69b Refactor the process creation code on POSIX platforms
This moved the process creation code to a class, and splits the
single function used before into several methods operation on instance
variables.

The refactor revealed at least one leaked file descriptor.

R=kustermann@google.com
BUG=

Review URL: https://codereview.chromium.org//884143002

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@43280 260f80e4-7a28-3924-810f-c04153c831b5
2015-01-29 13:06:40 +00:00
sgjesse@google.com f1b1e4a8db Aling process implementation and fix bugs
Aling the code for dart:io process as much as possible between Linux,
Mac OS and Android prior to refactiring the code.

On Mac OS file descriptors where not closed corrently. On Linux EINTR
was not expected for all calls.

R=kustermann@google.com, kunstemann@google.com
BUG=

Review URL: https://codereview.chromium.org//882093002

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@43274 260f80e4-7a28-3924-810f-c04153c831b5
2015-01-29 11:54:54 +00:00
sgjesse@google.com f6a10fbdf1 Add support for starting a detached process
BUG=http://dartbug.com/20970
R=kustermann@google.com, lrn@google.com

Review URL: https://codereview.chromium.org//798743004

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@43070 260f80e4-7a28-3924-810f-c04153c831b5
2015-01-22 11:49:39 +00:00
iposva@google.com 5a383e7add - Make sure that the threads for dart::bin are in the correct namespace.
R=asiva@google.com

Review URL: https://codereview.chromium.org//471743002

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@39233 260f80e4-7a28-3924-810f-c04153c831b5
2014-08-14 00:06:04 +00:00
iposva@google.com 14ecdbd66a - Separate the thread implementation used in bin/ and vm/
to allow us to make VM specific changes.

R=asiva@google.com

Review URL: https://codereview.chromium.org//463993002

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@39172 260f80e4-7a28-3924-810f-c04153c831b5
2014-08-12 23:19:53 +00:00
ajohnsen@google.com 6906b3ba5f Fix listening for multiple signals.
BUG=https://code.google.com/p/dart/issues/detail?id=18793
R=sgjesse@google.com

Review URL: https://codereview.chromium.org//285023002

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@36153 260f80e4-7a28-3924-810f-c04153c831b5
2014-05-14 09:36:03 +00:00
ajohnsen@google.com 03429c2ee6 Allow internal usage of SIGQUIT signal listening.
BUG=
R=sgjesse@google.com

Review URL: https://codereview.chromium.org//262463002

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@35616 260f80e4-7a28-3924-810f-c04153c831b5
2014-05-01 08:01:09 +00:00
ajohnsen@google.com ca58691974 Mark pipe as close-on-exec.
BUG=
R=sgjesse@google.com

Review URL: https://codereview.chromium.org//251403004

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@35354 260f80e4-7a28-3924-810f-c04153c831b5
2014-04-24 07:34:07 +00:00
ajohnsen@google.com 59fcec073c Don't make the signal-pipe non-blocking.
This is an attempt to make it run on MIPS. The non-blocking is not
needed here.

BUG=https://code.google.com/p/dart/issues/detail?id=17826
R=sgjesse@google.com

Review URL: https://codereview.chromium.org//220863003

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@34594 260f80e4-7a28-3924-810f-c04153c831b5
2014-04-01 12:15:21 +00:00
ajohnsen@google.com 0c157cd31e Move signal_blocker to platform and use it by default in TEMP_FAILURE_RETRY.
BUG=http://code.google.com/p/dart/issues/detail?id=16927
R=johnmccutchan@google.com, sgjesse@google.com

Review URL: https://codereview.chromium.org//165723007

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@33745 260f80e4-7a28-3924-810f-c04153c831b5
2014-03-17 13:51:11 +00:00
ajohnsen@google.com 36ba03fd0c Use signal-block around fork() to avoid we block it.
This issue is seen on a single-core VM.

BUG=https://code.google.com/p/dart/issues/detail?id=17217
R=johnmccutchan@google.com

Review URL: https://codereview.chromium.org//176933006

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@33219 260f80e4-7a28-3924-810f-c04153c831b5
2014-03-03 15:38:22 +00:00
ajohnsen@google.com 2f60129fb0 Document ProcessSignal::watch.
We now also allow watching for SIGTERM.

BUG=
R=sgjesse@google.com

Review URL: https://codereview.chromium.org//149253013

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@32416 260f80e4-7a28-3924-810f-c04153c831b5
2014-02-07 09:41:38 +00:00
ajohnsen@google.com 3bc42be527 Block other signals while handling a signal.
BUG=
R=sgjesse@google.com

Review URL: https://codereview.chromium.org//118713003

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@31331 260f80e4-7a28-3924-810f-c04153c831b5
2013-12-20 12:12:17 +00:00
ajohnsen@google.com 38d0fad2c7 Signal handling, take 2.
BUG=
R=sgjesse@google.com

Review URL: https://codereview.chromium.org//119093007

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@31276 260f80e4-7a28-3924-810f-c04153c831b5
2013-12-19 15:07:48 +00:00
ajohnsen@google.com f24f568571 Revert "Signal handling."
This reverts commit r31270.

BUG=

Review URL: https://codereview.chromium.org//105083009

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@31275 260f80e4-7a28-3924-810f-c04153c831b5
2013-12-19 14:03:15 +00:00
ajohnsen@google.com e8d9794c70 Signal handling.
BUG=
R=sgjesse@google.com

Review URL: https://codereview.chromium.org//108003009

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@31270 260f80e4-7a28-3924-810f-c04153c831b5
2013-12-19 13:08:26 +00:00
ajohnsen@google.com 1cd800214f Always wait for child processes when forked, even if the process failed.
BUG=
R=sgjesse@google.com

Review URL: https://codereview.chromium.org//23494048

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@27384 260f80e4-7a28-3924-810f-c04153c831b5
2013-09-11 14:29:23 +00:00
ajohnsen@google.com 6949a7bd08 Simplify process exit-code handling on Posix, take 2.
As in https://codereview.chromium.org/24024007, except the monitor->Wait
is now called in a loop with a guard, to ensure we actually do get notified.

Also, now correctly exiting the thread if we have no more child
processes, using the initialize/terminate mutex as guard.

BUG=
R=sgjesse@google.com

Review URL: https://codereview.chromium.org//23717038

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@27380 260f80e4-7a28-3924-810f-c04153c831b5
2013-09-11 13:05:13 +00:00
ajohnsen@google.com bce63cccc9 Revert "Simplify process exit-code handling on Posix."
This reverts commit f1b1ba410e964b0f787513f245faf8b457c9331a.

BUG=

Review URL: https://codereview.chromium.org//23536032

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@27251 260f80e4-7a28-3924-810f-c04153c831b5
2013-09-06 15:02:31 +00:00
ajohnsen@google.com 5e4135c731 Simplify process exit-code handling on Posix.
We now only use waitpid and not signals. When we exit, we perform a
small fork-and-exit to interrupt waitpid, so it can exit the thread.

BUG=
R=sgjesse@google.com

Review URL: https://codereview.chromium.org//24024007

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@27247 260f80e4-7a28-3924-810f-c04153c831b5
2013-09-06 13:08:34 +00:00
sgjesse@google.com f235a79d0d Remove ASSERT which was reported as a race by ThreadSanitizer
R=whesse@google.com
BUG=

Review URL: https://codereview.chromium.org//23903007

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@27131 260f80e4-7a28-3924-810f-c04153c831b5
2013-09-04 13:52:59 +00:00
whesse@google.com 6de4e020f2 Fix android compilation by copying process_linux.cc to process_android.cc.
These files, in runtime/bin, are the native functions supporting the dart:io
Process class.  The android version hadn't been updated when the linux version was changed.

BUG=
R=sgjesse@google.com

Review URL: https://codereview.chromium.org//23428002

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@26642 260f80e4-7a28-3924-810f-c04153c831b5
2013-08-26 12:28:08 +00:00
sgjesse@google.com 7c98c1fc66 Fix Process.runSync on 64-bit Mac OS
Turned out that for poll on 64-bin Mac OS POLLIN set with 0 available
bytes means closed even though POLLHUP is not set.

Also slighty refactored the loop in the Linux version to make them
look the same.

R=whesse@google.com
BUG=

Review URL: https://codereview.chromium.org//23076002

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@26057 260f80e4-7a28-3924-810f-c04153c831b5
2013-08-13 15:56:47 +00:00
sgjesse@google.com 959456533f Add Process.runSync for running processes synchronously
BUG=http://dartbug.com/1707

R=whesse@google.com

Review URL: https://codereview.chromium.org//21816002

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@26052 260f80e4-7a28-3924-810f-c04153c831b5
2013-08-13 14:12:31 +00:00
cbracken@google.com a6ace331f3 Replaced strerror() calls with threadsafe strerror_r().
Mac/Android use the XSI-compliant definition of strerror_r() which stores the message in the passed-in buffer.

Linux uses the GNU-specific definition of strerror_r() which takes a buffer and returns the message in a char* (which may or may not be the passed-in buffer).

BUG=
R=iposva@google.com

Review URL: https://codereview.chromium.org//22634003

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@25943 260f80e4-7a28-3924-810f-c04153c831b5
2013-08-08 20:24:05 +00:00
ajohnsen@google.com 900dba8e03 Remove static mutexes/monitors from dart:io.
BUG=
R=whesse@google.com

Review URL: https://codereview.chromium.org//18080010

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@24576 260f80e4-7a28-3924-810f-c04153c831b5
2013-06-28 08:44:15 +00:00
kustermann@google.com ba62bae621 Fix for leaking file descriptor issue
When calling a non-existent executable, a pair of file descriptors will be
created with pipe(). One end goes to the exitcode handler thread, the other end
goes to the epoll() thread.

If an error occurs during process creation, the pipe is still created and the
exit handler thread writes the exitcode to the pipe, but the other file
descriptor is not added to the epoll() set and is therefore leaked. (i.e.
Process_Start ignores the other end of the pipe if exec() failed in
Proces::Start()).

R=sgjesse@google.com

Review URL: https://codereview.chromium.org//15980006

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@23534 260f80e4-7a28-3924-810f-c04153c831b5
2013-06-03 09:41:36 +00:00
smok@google.com ebbc2020a2 Put everything in runtime/bin into '::dart::bin' namespace.
Review URL: https://codereview.chromium.org//14341015

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@22032 260f80e4-7a28-3924-810f-c04153c831b5
2013-04-25 14:22:30 +00:00
kustermann@google.com 2eb595367c Fix of file descriptor inheritance problem in process_{linux,android,mac}
BUG=http://dartbug.com/9030

Review URL: https://codereview.chromium.org//12576007

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@19790 260f80e4-7a28-3924-810f-c04153c831b5
2013-03-11 13:35:38 +00:00
iposva@google.com 9046a44a37 Prepare for removal of source_filter.gypi:
- Guard OS-dependent source files with #if TARGET_OS_* in a similar
  fashion to the architecture dependent sources.
Review URL: https://codereview.chromium.org//12282051

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@18786 260f80e4-7a28-3924-810f-c04153c831b5
2013-02-20 21:17:38 +00:00
kustermann@google.com c20c523de8 Set close-on-exec flag on pipe() and epoll() file descriptors
Review URL: https://codereview.chromium.org//11644017

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@16308 260f80e4-7a28-3924-810f-c04153c831b5
2012-12-19 09:36:47 +00:00
ager@google.com 8a14c1c319 Use FormatMessageW for Windows error messages to handle internationalized messages correctly.
R=sgjesse@google.com
BUG=dartbug.com/6986

Review URL: https://codereview.chromium.org//11558012

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@16041 260f80e4-7a28-3924-810f-c04153c831b5
2012-12-12 14:39:21 +00:00
gram@google.com 3601944836 Revised CL for customisable logging (replacing printfs).
Review URL: https://codereview.chromium.org//11312242

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@15096 260f80e4-7a28-3924-810f-c04153c831b5
2012-11-19 17:38:15 +00:00
rnystrom@google.com 908b045578 Look up executable on PATH when given environment variables.
Fixes http://code.google.com/p/dart/issues/detail?id=4402

Review URL: https://codereview.chromium.org//11260048

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@14300 260f80e4-7a28-3924-810f-c04153c831b5
2012-10-30 18:17:51 +00:00
ager@google.com 79a0089d38 Change Process.kill to return a boolean instead of throwing an exception when kill fails.
If the program wants to kill the process after a given time, it is
possible that the process is already dead but has not yet been
reaped. Therefore, there is no way for the programmer to test if the
process is already dead before killing it. Throwing an exception from
kill is not helpful as you will most often have to catch it and do
nothing because you cannot prevent the exception occasionally and
there is nothing you can do as a result of the exception since it
usually means that the process is already dead.

R=ahe@google.com,sgjesse@google.com
BUG=

Review URL: https://codereview.chromium.org//11238057

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@13956 260f80e4-7a28-3924-810f-c04153c831b5
2012-10-23 12:40:53 +00:00
cshapiro@google.com 772a399cab Emit symbol maps for compiled code for use by the Linux perf tool.
Review URL: https://chromiumcodereview.appspot.com//10831005

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@9922 260f80e4-7a28-3924-810f-c04153c831b5
2012-07-26 00:21:25 +00:00
whesse@google.com d05e40212a IO: Fix error in Process exit handling.
BUG=3639
TEST=

Review URL: https://chromiumcodereview.appspot.com//10697066

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@9336 260f80e4-7a28-3924-810f-c04153c831b5
2012-07-03 10:16:25 +00:00
ajohnsen@google.com c54800f942 Give Process.kill an optional argument to specify which signal to send.
BUG=
TEST=

Review URL: https://chromiumcodereview.appspot.com//10545134

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@8541 260f80e4-7a28-3924-810f-c04153c831b5
2012-06-12 12:00:50 +00:00
ager@google.com 493a76dd40 Support passing an environment variable map to child processes.
Fix minor type warning in test.

Reapplication after MacOS bug fix.

R=sgjesse@google.com
BUG=dartbug.com/2193
TEST=

Review URL: https://chromiumcodereview.appspot.com//10166029

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@6827 260f80e4-7a28-3924-810f-c04153c831b5
2012-04-23 07:54:10 +00:00
ager@google.com c5d347fcbc Revert "Support passing an environment variable map to child processes."
Apparently the code or the test is broken on Mac.

R=sgjesse@google.com
BUG=
TEST=

Review URL: https://chromiumcodereview.appspot.com//10163004

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@6795 260f80e4-7a28-3924-810f-c04153c831b5
2012-04-20 12:53:19 +00:00
ager@google.com ee81b6f0a1 Support passing an environment variable map to child processes.
Fix minor type warning in test.

R=sgjesse@google.com
BUG=dartbug.com/2193
TEST=

Review URL: https://chromiumcodereview.appspot.com//10127008

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@6794 260f80e4-7a28-3924-810f-c04153c831b5
2012-04-20 12:38:57 +00:00
ager@google.com 37499dce81 Rework Windows process handling.
- Use only one thread to wait for multiple process objects.
- Fix issue where reading from a closed pipe would print an
  error message on stderr.
- Remove the need to go to dart before removing a processinfo
  object from the list. Sometimes you never get there so we
  have to remove the process info object always.

BUG=
TEST=

Review URL: https://chromiumcodereview.appspot.com//9310053

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@3844 260f80e4-7a28-3924-810f-c04153c831b5
2012-02-02 13:47:42 +00:00
sgjesse@google.com 42b70dcddb Change the thread interface in runtime/platform and use it starting all threads
The platform thread interface (dart::thread) is now refactored to an
all static interface as suggested by iposva@ and asiva@. Use this
interface for running all threads in the VM.

R=ager@google.com, iposva@google.com

BUG=
TEST=

Review URL: https://chromiumcodereview.appspot.com//9141005

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@3830 260f80e4-7a28-3924-810f-c04153c831b5
2012-02-02 08:59:26 +00:00
ager@google.com ed3338dbae Wait for exit-code thread to terminate before terminating main.
The code is identical on Linux and Mac. Currently unimplemented on
Windows because I had to revert my change to the exit code handling
on Windows. I will revive that change tomorrow and implement this
as part of that change.

R=iposva@google.com
BUG=
TEST=

Review URL: https://chromiumcodereview.appspot.com//9315037

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@3801 260f80e4-7a28-3924-810f-c04153c831b5
2012-02-01 18:16:45 +00:00
ager@google.com 7031be2291 Revert "Changes to the process implementation."
There is a race-condition on Windows and exit handling when a process
has been closed is incorrect.

R=sgjesse@google.com
BUG=
TEST=

Review URL: https://chromiumcodereview.appspot.com//9307033

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@3790 260f80e4-7a28-3924-810f-c04153c831b5
2012-02-01 14:19:25 +00:00
ager@google.com 6b5815328c Changes to the process implementation.
- Make the list of active processes thread safe on Windows.
- Use only one thread on Windows to detect process termination.
- Stop the process termination thread when the standalone VM terminates.

R=sgjesse@google.com
BUG=
TEST=

Review URL: https://chromiumcodereview.appspot.com//9307003

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@3780 260f80e4-7a28-3924-810f-c04153c831b5
2012-02-01 09:09:23 +00:00