Changeset 2872
- Timestamp:
- 11/13/07 09:59:16 (1 year ago)
- Files:
-
- trunk/tango/sys/Process.d (modified) (12 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/tango/sys/Process.d
r2870 r2872 255 255 public ~this() 256 256 { 257 clean(); 257 _running = false; 258 cleanPipes(); 258 259 } 259 260 … … 418 419 * 419 420 * Remarks: 420 * The process must be running before calling this method.421 * The stream will be null if no child process has been executed. 421 422 */ 422 423 public OutputStream stdin() 423 in424 {425 assert(_running);426 }427 body428 424 { 429 425 return _stdin; … … 437 433 * 438 434 * Remarks: 439 * The process must be running before calling this method.435 * The stream will be null if no child process has been executed. 440 436 */ 441 437 public InputStream stdout() 442 in443 {444 assert(_running);445 }446 body447 438 { 448 439 return _stdout; … … 456 447 * 457 448 * Remarks: 458 * The process must be running before calling this method.449 * The stream will be null if no child process has been executed. 459 450 */ 460 451 public InputStream stderr() 461 in462 {463 assert(_running);464 }465 body466 452 { 467 453 return _stderr; … … 616 602 SECURITY_ATTRIBUTES sa; 617 603 STARTUPINFO startup; 604 605 // We close and delete the pipes that could have been left open 606 // from a previous execution. 607 cleanPipes(); 618 608 619 609 // Set up the security attributes struct. … … 679 669 else version (Posix) 680 670 { 671 // We close and delete the pipes that could have been left open 672 // from a previous execution. 673 cleanPipes(); 674 681 675 Pipe pin = new Pipe(DefaultStdinBufferSize); 682 676 Pipe pout = new Pipe(DefaultStdoutBufferSize); … … 864 858 assert(_info !is null); 865 859 866 // We clean up once we're done waiting for the process to finish. 860 // We clean up the process related data and set the _running 861 // flag to false once we're done waiting for the process to 862 // finish. 863 // 864 // IMPORTANT: we don't delete the open pipes so that the parent 865 // process can get whatever the child process left on 866 // these pipes before dying. 867 867 scope(exit) 868 868 { 869 869 CloseHandle(_info.hProcess); 870 clean();870 _running = false; 871 871 } 872 872 … … 911 911 { 912 912 int rc; 913 914 // We clean up the process related data and set the _running 915 // flag to false once we're done waiting for the process to 916 // finish. 917 // 918 // IMPORTANT: we don't delete the open pipes so that the parent 919 // process can get whatever the child process left on 920 // these pipes before dying. 921 scope(exit) 922 { 923 _running = false; 924 } 913 925 914 926 // Wait for child process to end. … … 979 991 _args[0], _pid, result.status, SysError.lastMsg); 980 992 } 981 clean();982 993 } 983 994 else … … 1022 1033 assert(_info !is null); 1023 1034 1035 // We clean up the process related data and set the _running 1036 // flag to false once we're done waiting for the process to 1037 // finish. 1038 // 1039 // IMPORTANT: we don't delete the open pipes so that the parent 1040 // process can get whatever the child process left on 1041 // these pipes before dying. 1024 1042 scope(exit) 1025 1043 { 1026 1044 CloseHandle(_info.hProcess); 1027 clean();1045 _running = false; 1028 1046 } 1029 1047 … … 1057 1075 if (.kill(_pid, SIGTERM) != -1) 1058 1076 { 1077 // We clean up the process related data and set the _running 1078 // flag to false once we're done waiting for the process to 1079 // finish. 1080 // 1081 // IMPORTANT: we don't delete the open pipes so that the parent 1082 // process can get whatever the child process left on 1083 // these pipes before dying. 1059 1084 scope(exit) 1060 clean(); 1085 { 1086 _running = false; 1087 } 1061 1088 1062 1089 // FIXME: is this loop really needed? … … 1227 1254 1228 1255 /** 1229 * Reset the object to its initial state.1230 * /1231 protected void clean()1232 {1233 _running = false;1256 * Close and delete any pipe that may have been left open in a previous 1257 * execution of a child process. 1258 */ 1259 protected void cleanPipes() 1260 { 1234 1261 delete _stdin; 1235 1262 delete _stdout;












