OLD | NEW |
1 // Copyright 2009 the V8 project authors. All rights reserved. | 1 // Copyright 2009 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
304 } | 304 } |
305 | 305 |
306 | 306 |
307 // Accumulates the output from the child in a string handle. Returns true if it | 307 // Accumulates the output from the child in a string handle. Returns true if it |
308 // succeeded or false if an exception was thrown. | 308 // succeeded or false if an exception was thrown. |
309 static Handle<Value> GetStdout(int child_fd, | 309 static Handle<Value> GetStdout(int child_fd, |
310 struct timeval& start_time, | 310 struct timeval& start_time, |
311 int read_timeout, | 311 int read_timeout, |
312 int total_timeout) { | 312 int total_timeout) { |
313 Handle<String> accumulator = String::Empty(); | 313 Handle<String> accumulator = String::Empty(); |
314 const char* source = "function(a, b) { return a + b; }"; | 314 const char* source = "(function(a, b) { return a + b; })"; |
315 Handle<Value> cons_as_obj(Script::Compile(String::New(source))->Run()); | 315 Handle<Value> cons_as_obj(Script::Compile(String::New(source))->Run()); |
316 Handle<Function> cons_function(Function::Cast(*cons_as_obj)); | 316 Handle<Function> cons_function(Function::Cast(*cons_as_obj)); |
317 Handle<Value> cons_args[2]; | 317 Handle<Value> cons_args[2]; |
318 | 318 |
319 int fullness = 0; | 319 int fullness = 0; |
320 static const int kStdoutReadBufferSize = 4096; | 320 static const int kStdoutReadBufferSize = 4096; |
321 char buffer[kStdoutReadBufferSize]; | 321 char buffer[kStdoutReadBufferSize]; |
322 | 322 |
323 if (fcntl(child_fd, F_SETFL, O_NONBLOCK) != 0) { | 323 if (fcntl(child_fd, F_SETFL, O_NONBLOCK) != 0) { |
324 return ThrowException(String::New(strerror(errno))); | 324 return ThrowException(String::New(strerror(errno))); |
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
666 void Shell::AddOSMethods(Handle<ObjectTemplate> os_templ) { | 666 void Shell::AddOSMethods(Handle<ObjectTemplate> os_templ) { |
667 os_templ->Set(String::New("system"), FunctionTemplate::New(System)); | 667 os_templ->Set(String::New("system"), FunctionTemplate::New(System)); |
668 os_templ->Set(String::New("chdir"), FunctionTemplate::New(ChangeDirectory)); | 668 os_templ->Set(String::New("chdir"), FunctionTemplate::New(ChangeDirectory)); |
669 os_templ->Set(String::New("setenv"), FunctionTemplate::New(SetEnvironment)); | 669 os_templ->Set(String::New("setenv"), FunctionTemplate::New(SetEnvironment)); |
670 os_templ->Set(String::New("umask"), FunctionTemplate::New(SetUMask)); | 670 os_templ->Set(String::New("umask"), FunctionTemplate::New(SetUMask)); |
671 os_templ->Set(String::New("mkdirp"), FunctionTemplate::New(MakeDirectory)); | 671 os_templ->Set(String::New("mkdirp"), FunctionTemplate::New(MakeDirectory)); |
672 os_templ->Set(String::New("rmdir"), FunctionTemplate::New(RemoveDirectory)); | 672 os_templ->Set(String::New("rmdir"), FunctionTemplate::New(RemoveDirectory)); |
673 } | 673 } |
674 | 674 |
675 } // namespace v8 | 675 } // namespace v8 |
OLD | NEW |