OLD | NEW |
1 // Copyright 2009 the V8 project authors. All rights reserved. | 1 // Copyright 2009 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <errno.h> | 5 #include <errno.h> |
6 #include <fcntl.h> | 6 #include <fcntl.h> |
7 #include <signal.h> | 7 #include <signal.h> |
8 #include <stdlib.h> | 8 #include <stdlib.h> |
9 #include <string.h> | 9 #include <string.h> |
10 #include <sys/stat.h> | 10 #include <sys/stat.h> |
(...skipping 513 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
524 exit(1); | 524 exit(1); |
525 } | 525 } |
526 | 526 |
527 // Parent process. Ensure that we clean up if we exit this function early. | 527 // Parent process. Ensure that we clean up if we exit this function early. |
528 ZombieProtector child_waiter(pid); | 528 ZombieProtector child_waiter(pid); |
529 close(exec_error_fds[kWriteFD]); | 529 close(exec_error_fds[kWriteFD]); |
530 close(stdout_fds[kWriteFD]); | 530 close(stdout_fds[kWriteFD]); |
531 OpenFDCloser error_read_closer(exec_error_fds[kReadFD]); | 531 OpenFDCloser error_read_closer(exec_error_fds[kReadFD]); |
532 OpenFDCloser stdout_read_closer(stdout_fds[kReadFD]); | 532 OpenFDCloser stdout_read_closer(stdout_fds[kReadFD]); |
533 | 533 |
534 if (!ChildLaunchedOK(args.GetIsolate(), exec_error_fds)) return; | 534 Isolate* isolate = args.GetIsolate(); |
| 535 if (!ChildLaunchedOK(isolate, exec_error_fds)) return; |
535 | 536 |
536 Local<Value> accumulator = GetStdout(args.GetIsolate(), stdout_fds[kReadFD], | 537 Local<Value> accumulator = GetStdout(isolate, stdout_fds[kReadFD], start_time, |
537 start_time, read_timeout, total_timeout); | 538 read_timeout, total_timeout); |
538 if (accumulator->IsUndefined()) { | 539 if (accumulator->IsUndefined()) { |
539 kill(pid, SIGINT); // On timeout, kill the subprocess. | 540 kill(pid, SIGINT); // On timeout, kill the subprocess. |
540 args.GetReturnValue().Set(accumulator); | 541 args.GetReturnValue().Set(accumulator); |
541 return; | 542 return; |
542 } | 543 } |
543 | 544 |
544 if (!WaitForChild(args.GetIsolate(), | 545 if (!WaitForChild(isolate, pid, child_waiter, start_time, read_timeout, |
545 pid, | |
546 child_waiter, | |
547 start_time, | |
548 read_timeout, | |
549 total_timeout)) { | 546 total_timeout)) { |
550 return; | 547 return; |
551 } | 548 } |
552 | 549 |
553 args.GetReturnValue().Set(accumulator); | 550 args.GetReturnValue().Set(accumulator); |
554 } | 551 } |
555 | 552 |
556 | 553 |
557 void Shell::ChangeDirectory(const v8::FunctionCallbackInfo<v8::Value>& args) { | 554 void Shell::ChangeDirectory(const v8::FunctionCallbackInfo<v8::Value>& args) { |
558 if (args.Length() != 1) { | 555 if (args.Length() != 1) { |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
782 FunctionTemplate::New(isolate, SetUMask)); | 779 FunctionTemplate::New(isolate, SetUMask)); |
783 os_templ->Set(String::NewFromUtf8(isolate, "mkdirp", NewStringType::kNormal) | 780 os_templ->Set(String::NewFromUtf8(isolate, "mkdirp", NewStringType::kNormal) |
784 .ToLocalChecked(), | 781 .ToLocalChecked(), |
785 FunctionTemplate::New(isolate, MakeDirectory)); | 782 FunctionTemplate::New(isolate, MakeDirectory)); |
786 os_templ->Set(String::NewFromUtf8(isolate, "rmdir", NewStringType::kNormal) | 783 os_templ->Set(String::NewFromUtf8(isolate, "rmdir", NewStringType::kNormal) |
787 .ToLocalChecked(), | 784 .ToLocalChecked(), |
788 FunctionTemplate::New(isolate, RemoveDirectory)); | 785 FunctionTemplate::New(isolate, RemoveDirectory)); |
789 } | 786 } |
790 | 787 |
791 } // namespace v8 | 788 } // namespace v8 |
OLD | NEW |