3853 "Modified: / 20-01-1998 / 16:57:19 / md" |
3853 "Modified: / 20-01-1998 / 16:57:19 / md" |
3854 "Modified: / 11-02-2007 / 20:51:08 / cg" |
3854 "Modified: / 11-02-2007 / 20:51:08 / cg" |
3855 ! |
3855 ! |
3856 |
3856 |
3857 exec:aCommandPath withArguments:argString environment:environment fileDescriptors:fdArray fork:doFork |
3857 exec:aCommandPath withArguments:argString environment:environment fileDescriptors:fdArray fork:doFork |
3858 newPgrp:newPgrp inDirectory:aDirectory |
3858 newPgrp:newPgrp inDirectory:aDirectory |
3859 showWindow:showWindowBooleanOrNil |
3859 showWindow:showWindowBooleanOrNil |
3860 |
3860 |
3861 "Internal lowLevel entry for combined fork & exec for WIN32 |
3861 "Internal lowLevel entry for combined fork & exec for WIN32 |
3862 |
3862 |
3863 If fork is false (chain a command): |
3863 If fork is false (chain a command): |
3864 execute the OS command specified by the argument, aCommandPath, with |
3864 execute the OS command specified by the argument, aCommandPath, with |
3865 arguments in argArray (no arguments, if nil). |
3865 arguments in argArray (no arguments, if nil). |
3866 If successful, this method does not return and smalltalk is gone. |
3866 If successful, this method does not return and smalltalk is gone. |
3867 If not successful, it does return. |
3867 If not successful, it does return. |
3868 Normal use is with forkForCommand. |
3868 Normal use is with forkForCommand. |
3869 |
3869 |
3870 If fork is true (subprocess command execution): |
3870 If fork is true (subprocess command execution): |
3871 fork a child to do the above. |
3871 fork a child to do the above. |
3872 The Win32ProcessHandle of the child process is returned; nil if the fork failed. |
3872 The Win32ProcessHandle of the child process is returned; nil if the fork failed. |
3873 |
3873 |
3874 fdArray contains the filedescriptors, to be used for the child (if fork is true). |
3874 fdArray contains the filedescriptors, to be used for the child (if fork is true). |
3875 fdArray[1] = 15 -> use fd 15 as stdin. |
3875 fdArray[1] = 15 -> use fd 15 as stdin. |
3876 If an element of the array is set to nil, the corresponding filedescriptor |
3876 If an element of the array is set to nil, the corresponding filedescriptor |
3877 will be closed for the child. |
3877 will be closed for the child. |
3878 fdArray[0] == StdIn for child |
3878 fdArray[0] == StdIn for child |
3879 fdArray[1] == StdOut for child |
3879 fdArray[1] == StdOut for child |
3880 fdArray[2] == StdErr for child |
3880 fdArray[2] == StdErr for child |
3881 |
3881 |
3882 NOTE that in WIN32 the fds are HANDLES. |
3882 NOTE that in WIN32 the fds are HANDLES. |
3883 |
3883 |
3884 If newPgrp is true, the subprocess will be established in a new process group. |
3884 If newPgrp is true, the subprocess will be established in a new process group. |
3885 The processgroup will be equal to id. |
3885 The processgroup will be equal to id. |
3886 newPgrp is not used on WIN32 and VMS systems. |
3886 newPgrp is not used on WIN32 and VMS systems. |
3887 |
3887 |
3888 showWindowOrBoolean may be: |
3888 showWindowOrBoolean may be: |
3889 true - a window is shown on start of the command |
3889 true - a window is shown on start of the command |
3890 false - the command window is hidden |
3890 false - the command window is hidden |
3891 nil - the nCmdShown parameter of the commans's winmain function determins, |
3891 nil - the nCmdShown parameter of the commans's winmain function determins, |
3892 if a window is shown. |
3892 if a window is shown. |
3893 #default |
3893 #default |
3894 - same as nil |
3894 - same as nil |
3895 " |
3895 " |
3896 |
3896 |
3897 |dirPath rslt| |
3897 |dirPath handle| |
3898 |
3898 |
3899 aDirectory notNil ifTrue:[ |
3899 aDirectory notNil ifTrue:[ |
3900 dirPath := aDirectory asFilename asAbsoluteFilename osNameForDirectory. |
3900 dirPath := aDirectory asFilename asAbsoluteFilename osNameForDirectory. |
3901 (dirPath endsWith:':') ifTrue:[ |
3901 (dirPath endsWith:':') ifTrue:[ |
3902 dirPath := dirPath , '\'. |
3902 dirPath := dirPath , '\'. |
3903 ]. |
3903 ]. |
3904 ]. |
3904 ]. |
3905 |
3905 |
3906 rslt := self |
3906 handle := self |
3907 primExec:aCommandPath |
3907 primExec:aCommandPath |
3908 commandLine:argString |
3908 commandLine:argString |
3909 environment:environment |
3909 environment:environment |
3910 fileDescriptors:fdArray |
3910 fileDescriptors:fdArray |
3911 fork:doFork |
3911 fork:doFork |
3912 newPgrp:newPgrp |
3912 newPgrp:newPgrp |
3913 inPath:dirPath |
3913 inPath:dirPath |
3914 createFlags:nil |
3914 createFlags:nil |
3915 inheritHandles:true |
3915 inheritHandles:true |
3916 showWindow:showWindowBooleanOrNil. |
3916 showWindow:showWindowBooleanOrNil. |
|
3917 |
|
3918 handle notNil ifTrue:[ |
|
3919 handle registerForFinalization. |
|
3920 ]. |
3917 |
3921 |
3918 "/ 'created ' print. cmdLine print. ' -> ' print. rslt printCR. |
3922 "/ 'created ' print. cmdLine print. ' -> ' print. rslt printCR. |
3919 ^ rslt |
3923 ^ handle |
3920 |
3924 |
3921 "Modified: / 31-01-1998 / 10:54:24 / md" |
3925 "Modified: / 31-01-1998 / 10:54:24 / md" |
3922 "Modified: / 15-05-1999 / 18:07:51 / cg" |
3926 "Modified: / 15-05-1999 / 18:07:51 / cg" |
3923 "Modified (comment): / 18-10-2016 / 16:00:26 / cg" |
3927 "Modified (comment): / 18-10-2016 / 16:00:26 / cg" |
|
3928 "Modified: / 22-01-2019 / 16:35:10 / Stefan Vogel" |
3924 ! |
3929 ! |
3925 |
3930 |
3926 getStatusOfProcess:aProcessId |
3931 getStatusOfProcess:aProcessId |
3927 "wait for a process to terminate and fetch its exit status. |
3932 "wait for a process to terminate and fetch its exit status. |
3928 This is required to avoid zombie processes." |
3933 This is required to avoid zombie processes." |