AbstractOperatingSystem.st
changeset 21328 4876615e4e0e
parent 21279 1a289f0af818
child 21387 e3865533e6a6
child 21396 f2a4828a45e7
equal deleted inserted replaced
21327:69016b4e8952 21328:4876615e4e0e
   189     "called at early startup to determine the kind of OS we are running on,
   189     "called at early startup to determine the kind of OS we are running on,
   190      and assigning a concrete subclass of me (remember: I am abstract) to the
   190      and assigning a concrete subclass of me (remember: I am abstract) to the
   191      global 'OperatingSystem'.
   191      global 'OperatingSystem'.
   192      Programs should never refer to any of my concrete classes directly, as
   192      Programs should never refer to any of my concrete classes directly, as
   193      they may not (will not) be present when ST/X is executed under anther OS."
   193      they may not (will not) be present when ST/X is executed under anther OS."
   194      
   194 
   195     |osType|
   195     |osType|
   196 
   196 
   197     osType := self getSystemType.
   197     osType := self getSystemType.
   198     osType = 'win32' ifTrue:[
   198     osType = 'win32' ifTrue:[
   199         ^ Win32OperatingSystem
   199 	^ Win32OperatingSystem
   200     ].
   200     ].
   201     osType = 'osx' ifTrue:[
   201     osType = 'osx' ifTrue:[
   202         ^ OSXOperatingSystem
   202 	^ OSXOperatingSystem
   203     ].
   203     ].
   204     osType = 'os2' ifTrue:[
   204     osType = 'os2' ifTrue:[
   205         ^ OS2OperatingSystem
   205 	^ OS2OperatingSystem
   206     ].
   206     ].
   207     osType = 'macos' ifTrue:[
   207     osType = 'macos' ifTrue:[
   208         ^ MacOperatingSystem
   208 	^ MacOperatingSystem
   209     ].
   209     ].
   210     ((osType = 'VMS') or:[osType = 'openVMS']) ifTrue:[
   210     ((osType = 'VMS') or:[osType = 'openVMS']) ifTrue:[
   211         ^ OpenVMSOperatingSystem
   211 	^ OpenVMSOperatingSystem
   212     ].
   212     ].
   213     ^ UnixOperatingSystem
   213     ^ UnixOperatingSystem
   214 !
   214 !
   215 
   215 
   216 initResources
   216 initResources
   621 
   621 
   622 openApplicationForDocument:aFilenameOrString operation:operationSymbol mimeType:mimeTypeStringArgOrNil
   622 openApplicationForDocument:aFilenameOrString operation:operationSymbol mimeType:mimeTypeStringArgOrNil
   623     "open a windows-shell/mac finder/desktop application to present the document contained in aFilenameOrString.
   623     "open a windows-shell/mac finder/desktop application to present the document contained in aFilenameOrString.
   624      This is typically used to present help-files, html documents, pdf documents etc.
   624      This is typically used to present help-files, html documents, pdf documents etc.
   625      operationSymbol is one of:
   625      operationSymbol is one of:
   626         open
   626 	open
   627         edit
   627 	edit
   628         explore
   628 	explore
   629      mimeTypeStringArgOrNil is e.g. 'text/html' or: 'application/pdf'.
   629      mimeTypeStringArgOrNil is e.g. 'text/html' or: 'application/pdf'.
   630      If nil is passed in, the file's suffix is used to guess the mime type.
   630      If nil is passed in, the file's suffix is used to guess the mime type.
   631     "
   631     "
   632 
   632 
   633     self
   633     self
   634         openApplicationForDocument:aFilenameOrString
   634 	openApplicationForDocument:aFilenameOrString
   635         operation:operationSymbol
   635 	operation:operationSymbol
   636         mimeType:mimeTypeStringArgOrNil
   636 	mimeType:mimeTypeStringArgOrNil
   637         inDirectory:nil
   637 	inDirectory:nil
   638         ifNone:[
   638 	ifNone:[
   639             "/ last resort: use a fileBrowser
   639 	    "/ last resort: use a fileBrowser
   640             UserPreferences fileBrowserClass openOn:aFilenameOrString
   640 	    UserPreferences fileBrowserClass openOn:aFilenameOrString
   641         ].
   641 	].
   642 
   642 
   643     "
   643     "
   644      self openApplicationForDocument: Filename currentDirectory operation:#open
   644      self openApplicationForDocument: Filename currentDirectory operation:#open
   645      self openApplicationForDocument: '..\..\doc\books\ArtOfSmalltalk\artMissing186187Fix1.pdf' asFilename operation:#open
   645      self openApplicationForDocument: '..\..\doc\books\ArtOfSmalltalk\artMissing186187Fix1.pdf' asFilename operation:#open
   646 
   646 
   654 
   654 
   655 openApplicationForDocument:aFilenameOrString operation:operationSymbol mimeType:mimeTypeStringArgOrNil ifNone:exceptionBlock
   655 openApplicationForDocument:aFilenameOrString operation:operationSymbol mimeType:mimeTypeStringArgOrNil ifNone:exceptionBlock
   656     "open a windows-shell/mac finder/desktop application to present the document contained in aFilenameOrString.
   656     "open a windows-shell/mac finder/desktop application to present the document contained in aFilenameOrString.
   657      This is typically used to present help-files, html documents, pdf documents etc.
   657      This is typically used to present help-files, html documents, pdf documents etc.
   658      operationSymbol is one of:
   658      operationSymbol is one of:
   659         open
   659 	open
   660         edit
   660 	edit
   661         explore
   661 	explore
   662      mimeTypeStringArgOrNil is e.g. 'text/html' or: 'application/pdf';
   662      mimeTypeStringArgOrNil is e.g. 'text/html' or: 'application/pdf';
   663      if nil is passed in, the file's suffix is used to guess it.
   663      if nil is passed in, the file's suffix is used to guess it.
   664     "
   664     "
   665 
   665 
   666     ^ self 
   666     ^ self
   667         openApplicationForDocument:aFilenameOrString operation:operationSymbol mimeType:mimeTypeStringArgOrNil 
   667 	openApplicationForDocument:aFilenameOrString operation:operationSymbol mimeType:mimeTypeStringArgOrNil
   668         inDirectory:nil ifNone:exceptionBlock
   668 	inDirectory:nil ifNone:exceptionBlock
   669 !
   669 !
   670 
   670 
   671 openApplicationForDocument:aFilenameOrString operation:operationSymbol mimeType:mimeTypeStringArgOrNil 
   671 openApplicationForDocument:aFilenameOrString operation:operationSymbol mimeType:mimeTypeStringArgOrNil
   672     inDirectory:directoryStringOrFilenameOrNil
   672     inDirectory:directoryStringOrFilenameOrNil
   673     "open a windows-shell/mac finder/desktop application to present the document contained in aFilenameOrString.
   673     "open a windows-shell/mac finder/desktop application to present the document contained in aFilenameOrString.
   674      This is typically used to present help-files, html documents, pdf documents etc.
   674      This is typically used to present help-files, html documents, pdf documents etc.
   675      operationSymbol is one of:
   675      operationSymbol is one of:
   676         open
   676 	open
   677         edit
   677 	edit
   678         explore
   678 	explore
   679      mimeTypeStringArgOrNil is e.g. 'text/html' or: 'application/pdf';
   679      mimeTypeStringArgOrNil is e.g. 'text/html' or: 'application/pdf';
   680      if nil is passed in, the file's suffix is used to guess it.
   680      if nil is passed in, the file's suffix is used to guess it.
   681     "
   681     "
   682 
   682 
   683     |openCommand mimeTypeString|
   683     |openCommand mimeTypeString|
   684 
   684 
   685     mimeTypeString := mimeTypeStringArgOrNil.
   685     mimeTypeString := mimeTypeStringArgOrNil.
   686 
   686 
   687     MIMETypes notNil ifTrue:[
   687     MIMETypes notNil ifTrue:[
   688         mimeTypeString isNil ifTrue:[
   688 	mimeTypeString isNil ifTrue:[
   689             mimeTypeString := MIMETypes mimeTypeForFilename:aFilenameOrString.
   689 	    mimeTypeString := MIMETypes mimeTypeForFilename:aFilenameOrString.
   690         ].
   690 	].
   691         mimeTypeString notNil ifTrue:[
   691 	mimeTypeString notNil ifTrue:[
   692             openCommand := MIMETypes defaultCommandTemplateToOpenMimeType:mimeTypeString.
   692 	    openCommand := MIMETypes defaultCommandTemplateToOpenMimeType:mimeTypeString.
   693         ].
   693 	].
   694     ].                                                                                         
   694     ].
   695     openCommand notEmptyOrNil ifTrue:[
   695     openCommand notEmptyOrNil ifTrue:[
   696         (openCommand includesSubString:'%1') ifTrue:[
   696 	(openCommand includesSubString:'%1') ifTrue:[
   697             openCommand := openCommand bindWith:aFilenameOrString asString.
   697 	    openCommand := openCommand bindWith:aFilenameOrString asString.
   698         ] ifFalse:[
   698 	] ifFalse:[
   699             openCommand := openCommand, ' "', aFilenameOrString asString, '"'.
   699 	    openCommand := openCommand, ' "', aFilenameOrString asString, '"'.
   700         ].
   700 	].
   701 
   701 
   702         (self
   702 	(self
   703                 startProcess:openCommand
   703 		startProcess:openCommand
   704                 inputFrom:nil outputTo:nil
   704 		inputFrom:nil outputTo:nil
   705                 errorTo:nil auxFrom:nil
   705 		errorTo:nil auxFrom:nil
   706                 environment:nil inDirectory:directoryStringOrFilenameOrNil) notNil
   706 		environment:nil inDirectory:directoryStringOrFilenameOrNil) notNil
   707         ifTrue:[
   707 	ifTrue:[
   708             ^ self.
   708 	    ^ self.
   709         ].
   709 	].
   710     ].
   710     ].
   711     ExecutionError raiseErrorString:'execution of command failed: ', openCommand.
   711     ExecutionError raiseErrorString:'execution of command failed: ', openCommand.
   712 
   712 
   713     "
   713     "
   714      self openApplicationForDocument: Filename currentDirectory operation:#open
   714      self openApplicationForDocument: Filename currentDirectory operation:#open
   719 
   719 
   720     "Created: / 29-10-2010 / 12:16:38 / cg"
   720     "Created: / 29-10-2010 / 12:16:38 / cg"
   721     "Modified: / 05-02-2011 / 16:13:42 / cg"
   721     "Modified: / 05-02-2011 / 16:13:42 / cg"
   722 !
   722 !
   723 
   723 
   724 openApplicationForDocument:aFilenameOrString operation:operationSymbol mimeType:mimeTypeStringArgOrNil 
   724 openApplicationForDocument:aFilenameOrString operation:operationSymbol mimeType:mimeTypeStringArgOrNil
   725     inDirectory:directoryStringOrFilenameOrNil ifNone:exceptionBlock
   725     inDirectory:directoryStringOrFilenameOrNil ifNone:exceptionBlock
   726     "open a windows-shell/mac finder/desktop application to present the document contained in aFilenameOrString.
   726     "open a windows-shell/mac finder/desktop application to present the document contained in aFilenameOrString.
   727      This is typically used to present help-files, html documents, pdf documents etc.
   727      This is typically used to present help-files, html documents, pdf documents etc.
   728      operationSymbol is one of:
   728      operationSymbol is one of:
   729         open
   729 	open
   730         edit
   730 	edit
   731         explore
   731 	explore
   732      mimeTypeStringArgOrNil is e.g. 'text/html' or: 'application/pdf';
   732      mimeTypeStringArgOrNil is e.g. 'text/html' or: 'application/pdf';
   733      if nil is passed in, the file's suffix is used to guess it.
   733      if nil is passed in, the file's suffix is used to guess it.
   734     "
   734     "
   735 
   735 
   736     [
   736     [
   737         ^ self 
   737 	^ self
   738             openApplicationForDocument:aFilenameOrString 
   738 	    openApplicationForDocument:aFilenameOrString
   739             operation:operationSymbol mimeType:mimeTypeStringArgOrNil 
   739 	    operation:operationSymbol mimeType:mimeTypeStringArgOrNil
   740             inDirectory:directoryStringOrFilenameOrNil.
   740 	    inDirectory:directoryStringOrFilenameOrNil.
   741     ] on:ExecutionError do:[:ex|
   741     ] on:ExecutionError do:[:ex|
   742         exceptionBlock value.
   742 	exceptionBlock value.
   743     ].
   743     ].
   744 ! !
   744 ! !
   745 
   745 
   746 !AbstractOperatingSystem class methodsFor:'error messages'!
   746 !AbstractOperatingSystem class methodsFor:'error messages'!
   747 
   747 
   905     "
   905     "
   906 ! !
   906 ! !
   907 
   907 
   908 !AbstractOperatingSystem class methodsFor:'executing OS commands-implementation'!
   908 !AbstractOperatingSystem class methodsFor:'executing OS commands-implementation'!
   909 
   909 
   910 exec:aCommandPath withArguments:argArray environment:env fileDescriptors:fds fork:doFork 
   910 exec:aCommandPath withArguments:argArray environment:env fileDescriptors:fds fork:doFork
   911                   newPgrp:newGrp inDirectory:aDirectory showWindow:showWindowBooleanOrNil
   911 		  newPgrp:newGrp inDirectory:aDirectory showWindow:showWindowBooleanOrNil
   912     "execute an OS command"
   912     "execute an OS command"
   913 
   913 
   914     ^ self subclassResponsibility
   914     ^ self subclassResponsibility
   915 
   915 
   916     "Created: / 12.11.1998 / 14:46:15 / cg"
   916     "Created: / 12.11.1998 / 14:46:15 / cg"
   953     |nullStream in out err shellAndArgs pid auxFd|
   953     |nullStream in out err shellAndArgs pid auxFd|
   954 
   954 
   955     aCommandString isNil ifTrue:[^ nil].
   955     aCommandString isNil ifTrue:[^ nil].
   956 
   956 
   957     (in := anExternalInStream) isNil ifTrue:[
   957     (in := anExternalInStream) isNil ifTrue:[
   958         nullStream := Filename nullDevice readWriteStream.
   958 	nullStream := Filename nullDevice readWriteStream.
   959         in := nullStream.
   959 	in := nullStream.
   960     ].
   960     ].
   961     (out := anExternalOutStream) isNil ifTrue:[
   961     (out := anExternalOutStream) isNil ifTrue:[
   962         nullStream isNil ifTrue:[nullStream := Filename nullDevice writeStream].
   962 	nullStream isNil ifTrue:[nullStream := Filename nullDevice writeStream].
   963         out := nullStream.
   963 	out := nullStream.
   964     ].
   964     ].
   965     (err := anExternalErrStream) isNil ifTrue:[
   965     (err := anExternalErrStream) isNil ifTrue:[
   966         err := out
   966 	err := out
   967     ].
   967     ].
   968     anAuxiliaryStream notNil ifTrue:[
   968     anAuxiliaryStream notNil ifTrue:[
   969         auxFd := anAuxiliaryStream fileHandle.
   969 	auxFd := anAuxiliaryStream fileHandle.
   970     ].
   970     ].
   971 
   971 
   972     shellAndArgs := self commandAndArgsForOSCommand:aCommandString.
   972     shellAndArgs := self commandAndArgsForOSCommand:aCommandString.
   973 
   973 
   974     pid := self
   974     pid := self
   975         exec:(shellAndArgs at:1)
   975 	exec:(shellAndArgs at:1)
   976         withArguments:(shellAndArgs at:2)
   976 	withArguments:(shellAndArgs at:2)
   977         environment:anEvironmentDictionary
   977 	environment:anEvironmentDictionary
   978         fileDescriptors:(Array with:in fileHandle
   978 	fileDescriptors:(Array with:in fileHandle
   979                                with:out fileHandle
   979 			       with:out fileHandle
   980                                with:err fileHandle
   980 			       with:err fileHandle
   981                                with:auxFd)
   981 			       with:auxFd)
   982         fork:true
   982 	fork:true
   983         newPgrp:newPgrp
   983 	newPgrp:newPgrp
   984         inDirectory:dir
   984 	inDirectory:dir
   985         showWindow:(showWindowBooleanOrNil ? (shellAndArgs at:3)).
   985 	showWindow:(showWindowBooleanOrNil ? (shellAndArgs at:3)).
   986 
   986 
   987     nullStream notNil ifTrue:[
   987     nullStream notNil ifTrue:[
   988         nullStream close.
   988 	nullStream close.
   989     ].
   989     ].
   990 
   990 
   991     ^ pid
   991     ^ pid
   992 
   992 
   993     "blocking at current prio (i.e. only higher prio threads execute):
   993     "blocking at current prio (i.e. only higher prio threads execute):
  1008      pid := OperatingSystem startProcess:'sleep 10; grep drw' inputFrom:in outputTo:out errorTo:err.
  1008      pid := OperatingSystem startProcess:'sleep 10; grep drw' inputFrom:in outputTo:out errorTo:err.
  1009 
  1009 
  1010      The following will no longer work. monitorPid has disappeared
  1010      The following will no longer work. monitorPid has disappeared
  1011 
  1011 
  1012      pid notNil ifTrue:[
  1012      pid notNil ifTrue:[
  1013          Processor monitorPid:pid action:[:osStatus | sema signal ].
  1013 	 Processor monitorPid:pid action:[:osStatus | sema signal ].
  1014      ].
  1014      ].
  1015      in close.
  1015      in close.
  1016      out close.
  1016      out close.
  1017      err close.
  1017      err close.
  1018      sema wait.
  1018      sema wait.
  1023      |pid sema|
  1023      |pid sema|
  1024 
  1024 
  1025      sema := Semaphore new.
  1025      sema := Semaphore new.
  1026 
  1026 
  1027      Processor
  1027      Processor
  1028             monitor:[
  1028 	    monitor:[
  1029                 pid := OperatingSystem startProcess:'(sleep 2; ls -l) > out 2>err'
  1029 		pid := OperatingSystem startProcess:'(sleep 2; ls -l) > out 2>err'
  1030             ]
  1030 	    ]
  1031             action:[:osStatus | sema signal ].
  1031 	    action:[:osStatus | sema signal ].
  1032 
  1032 
  1033      sema wait.
  1033      sema wait.
  1034      Transcript showCR:'finished'
  1034      Transcript showCR:'finished'
  1035     "
  1035     "
  1036 
  1036 
  1038      |pid sema|
  1038      |pid sema|
  1039 
  1039 
  1040      sema := Semaphore new.
  1040      sema := Semaphore new.
  1041 
  1041 
  1042      Processor
  1042      Processor
  1043             monitor:[
  1043 	    monitor:[
  1044                 pid := OperatingSystem startProcess:'(sleep 1; echo 1; sleep 9; ls -l) > out 2>err'
  1044 		pid := OperatingSystem startProcess:'(sleep 1; echo 1; sleep 9; ls -l) > out 2>err'
  1045             ]
  1045 	    ]
  1046             action:[:osStatus | sema signal ].
  1046 	    action:[:osStatus | sema signal ].
  1047 
  1047 
  1048      Delay waitForSeconds:2.
  1048      Delay waitForSeconds:2.
  1049      OperatingSystem terminateProcess:pid.
  1049      OperatingSystem terminateProcess:pid.
  1050      Transcript showCR:'terminated'
  1050      Transcript showCR:'terminated'
  1051     "
  1051     "
  1072      pid := OperatingSystem startProcess:'sleep 10; grep drw' inputFrom:in outputTo:out errorTo:err.
  1072      pid := OperatingSystem startProcess:'sleep 10; grep drw' inputFrom:in outputTo:out errorTo:err.
  1073 
  1073 
  1074      The following will no longer work. monitorPid has disappeared
  1074      The following will no longer work. monitorPid has disappeared
  1075 
  1075 
  1076      pid notNil ifTrue:[
  1076      pid notNil ifTrue:[
  1077          Processor monitorPid:pid action:[:OSstatus | sema signal ].
  1077 	 Processor monitorPid:pid action:[:OSstatus | sema signal ].
  1078      ].
  1078      ].
  1079      in close.
  1079      in close.
  1080      out close.
  1080      out close.
  1081      err close.
  1081      err close.
  1082      sema wait.
  1082      sema wait.
  1087      |pid sema|
  1087      |pid sema|
  1088 
  1088 
  1089      sema := Semaphore new.
  1089      sema := Semaphore new.
  1090 
  1090 
  1091      Processor
  1091      Processor
  1092             monitor:[
  1092 	    monitor:[
  1093                 pid := OperatingSystem startProcess:'dir > out 2>err'
  1093 		pid := OperatingSystem startProcess:'dir > out 2>err'
  1094             ]
  1094 	    ]
  1095             action:[:osStatus | sema signal ].
  1095 	    action:[:osStatus | sema signal ].
  1096 
  1096 
  1097      sema wait.
  1097      sema wait.
  1098      Transcript showCR:'finished'
  1098      Transcript showCR:'finished'
  1099     "
  1099     "
  1100 
  1100 
  1102      |pid sema|
  1102      |pid sema|
  1103 
  1103 
  1104      sema := Semaphore new.
  1104      sema := Semaphore new.
  1105 
  1105 
  1106      Processor
  1106      Processor
  1107             monitor:[
  1107 	    monitor:[
  1108                 pid := OperatingSystem startProcess:'(echo 1 & stx --eval "Delay waitForSeconds:100" & dir) >out' withCRs
  1108 		pid := OperatingSystem startProcess:'(echo 1 & stx --eval "Delay waitForSeconds:100" & dir) >out' withCRs
  1109             ]
  1109 	    ]
  1110             action:[:osStatus | sema signal ].
  1110 	    action:[:osStatus | sema signal ].
  1111 
  1111 
  1112      Delay waitForSeconds:5.
  1112      Delay waitForSeconds:5.
  1113      OperatingSystem terminateProcessGroup:pid.
  1113      OperatingSystem terminateProcessGroup:pid.
  1114      Transcript showCR:'terminated'
  1114      Transcript showCR:'terminated'
  1115 END"
  1115 END"
  1118      |pid sema|
  1118      |pid sema|
  1119 
  1119 
  1120      sema := Semaphore new.
  1120      sema := Semaphore new.
  1121 
  1121 
  1122      Processor
  1122      Processor
  1123             monitor:[
  1123 	    monitor:[
  1124                 pid := OperatingSystem startProcess:{ 'C:\Users\cg\work\stx\projects\smalltalk\stx.com' . '--eval' . '"Delay waitForSeconds:100"' }
  1124 		pid := OperatingSystem startProcess:{ 'C:\Users\cg\work\stx\projects\smalltalk\stx.com' . '--eval' . '"Delay waitForSeconds:100"' }
  1125             ]
  1125 	    ]
  1126             action:[:osStatus | sema signal ].
  1126 	    action:[:osStatus | sema signal ].
  1127 
  1127 
  1128      Delay waitForSeconds:5.
  1128      Delay waitForSeconds:5.
  1129      OperatingSystem terminateProcess:pid.
  1129      OperatingSystem terminateProcess:pid.
  1130      Transcript showCR:'terminated'
  1130      Transcript showCR:'terminated'
  1131 END"
  1131 END"
  1294      If aCommandString is an Array, the first element is the command to be executed,
  1294      If aCommandString is an Array, the first element is the command to be executed,
  1295      and the other elements are the arguments to the command. No shell is invoked in this case.
  1295      and the other elements are the arguments to the command. No shell is invoked in this case.
  1296      Return true if successful, false otherwise."
  1296      Return true if successful, false otherwise."
  1297 
  1297 
  1298     ^ self
  1298     ^ self
  1299         executeCommand:aCommandString
  1299 	executeCommand:aCommandString
  1300         inputFrom:nil
  1300 	inputFrom:nil
  1301         outputTo:nil
  1301 	outputTo:nil
  1302         errorTo:nil
  1302 	errorTo:nil
  1303         auxFrom:nil
  1303 	auxFrom:nil
  1304         environment:nil
  1304 	environment:nil
  1305         inDirectory:aDirectory
  1305 	inDirectory:aDirectory
  1306         lineWise:false
  1306 	lineWise:false
  1307         showWindow:showWindow
  1307 	showWindow:showWindow
  1308         onError:[:exitStatus| false]
  1308 	onError:[:exitStatus| false]
  1309 
  1309 
  1310     "Created: / 18-10-2016 / 15:55:29 / cg"
  1310     "Created: / 18-10-2016 / 15:55:29 / cg"
  1311 !
  1311 !
  1312 
  1312 
  1313 executeCommand:aCommandString inputFrom:anInStream outputTo:anOutStream errorTo:anErrStream
  1313 executeCommand:aCommandString inputFrom:anInStream outputTo:anOutStream errorTo:anErrStream
  1410      Set lineWise to true, if both error and output is sent to the same stream
  1410      Set lineWise to true, if both error and output is sent to the same stream
  1411      and you don't want lines to be mangled. Set lineWise = false to
  1411      and you don't want lines to be mangled. Set lineWise = false to
  1412      avoid blocking on pipes.
  1412      avoid blocking on pipes.
  1413 
  1413 
  1414      Special for windows:
  1414      Special for windows:
  1415         you can control (have to - sigh) if a window should be shown for the command or not.
  1415 	you can control (have to - sigh) if a window should be shown for the command or not.
  1416         This is the OS's H_SHOWWINDOW argument.
  1416 	This is the OS's H_SHOWWINDOW argument.
  1417         If you pass nil as showWindow-argument, the OS's default is used for the particular
  1417 	If you pass nil as showWindow-argument, the OS's default is used for the particular
  1418         command, which is correct most of the time: i.e. a notepad will open its window, other (non-UI)
  1418 	command, which is correct most of the time: i.e. a notepad will open its window, other (non-UI)
  1419         executables will not.
  1419 	executables will not.
  1420         However, some command-line executables show a window, even if they should not.
  1420 	However, some command-line executables show a window, even if they should not.
  1421         (and also, there seems to be an inconsistency between windows7 and newer windows: in newer,
  1421 	(and also, there seems to be an inconsistency between windows7 and newer windows: in newer,
  1422          a shell command opens a cmd-window, whereas in windows7 it did not)
  1422 	 a shell command opens a cmd-window, whereas in windows7 it did not)
  1423         In this case, pass an explicit false argument to suppress it.
  1423 	In this case, pass an explicit false argument to suppress it.
  1424         This argument is ignored on Unix systems.
  1424 	This argument is ignored on Unix systems.
  1425         See examples below."
  1425 	See examples below."
  1426 
  1426 
  1427         |osProcess|
  1427 	|osProcess|
  1428 
  1428 
  1429         osProcess := OSProcess new
  1429 	osProcess := OSProcess new
  1430             command:aCommandStringOrArray;
  1430 	    command:aCommandStringOrArray;
  1431             inStream:anInStream;
  1431 	    inStream:anInStream;
  1432             outStream:anOutStream;
  1432 	    outStream:anOutStream;
  1433             errorStream:anErrStream;
  1433 	    errorStream:anErrStream;
  1434             auxStream:anAuxStream;
  1434 	    auxStream:anAuxStream;
  1435             environment:environmentDictionary;
  1435 	    environment:environmentDictionary;
  1436             directory:dirOrNil;
  1436 	    directory:dirOrNil;
  1437             lineWise:lineWise;
  1437 	    lineWise:lineWise;
  1438             showWindow:showWindowBooleanOrNil.
  1438 	    showWindow:showWindowBooleanOrNil.
  1439 
  1439 
  1440         osProcess execute ifFalse:[
  1440 	osProcess execute ifFalse:[
  1441             aBlock value:osProcess exitStatus.
  1441 	    aBlock value:osProcess exitStatus.
  1442             ^ false.
  1442 	    ^ false.
  1443         ].
  1443 	].
  1444         ^ true.
  1444 	^ true.
  1445 !
  1445 !
  1446 
  1446 
  1447 executeCommand:aCommandStringOrArray inputFrom:anInStream outputTo:anOutStream
  1447 executeCommand:aCommandStringOrArray inputFrom:anInStream outputTo:anOutStream
  1448     errorTo:anErrStream auxFrom:anAuxStream environment:environmentDictionary
  1448     errorTo:anErrStream auxFrom:anAuxStream environment:environmentDictionary
  1449     inDirectory:dirOrNil lineWise:lineWise onError:aBlock
  1449     inDirectory:dirOrNil lineWise:lineWise onError:aBlock
  1466      Set lineWise to true, if both error and output is sent to the same stream
  1466      Set lineWise to true, if both error and output is sent to the same stream
  1467      and you don't want lines to be mangled. Set lineWise = false to
  1467      and you don't want lines to be mangled. Set lineWise = false to
  1468      avoid blocking on pipes"
  1468      avoid blocking on pipes"
  1469 
  1469 
  1470     ^ self
  1470     ^ self
  1471         executeCommand:aCommandStringOrArray inputFrom:anInStream outputTo:anOutStream
  1471 	executeCommand:aCommandStringOrArray inputFrom:anInStream outputTo:anOutStream
  1472         errorTo:anErrStream auxFrom:anAuxStream environment:environmentDictionary
  1472 	errorTo:anErrStream auxFrom:anAuxStream environment:environmentDictionary
  1473         inDirectory:dirOrNil lineWise:lineWise showWindow:false onError:aBlock
  1473 	inDirectory:dirOrNil lineWise:lineWise showWindow:false onError:aBlock
  1474 
  1474 
  1475     "
  1475     "
  1476         |outStream errStream|
  1476 	|outStream errStream|
  1477 
  1477 
  1478         outStream := '' writeStream.
  1478 	outStream := '' writeStream.
  1479 
  1479 
  1480         OperatingSystem executeCommand:'ls -l'
  1480 	OperatingSystem executeCommand:'ls -l'
  1481                         inputFrom:'abc' readStream
  1481 			inputFrom:'abc' readStream
  1482                         outputTo:outStream
  1482 			outputTo:outStream
  1483                         errorTo:nil
  1483 			errorTo:nil
  1484                         inDirectory:nil
  1484 			inDirectory:nil
  1485                         lineWise:true
  1485 			lineWise:true
  1486                         onError:[:exitStatus | ^ false].
  1486 			onError:[:exitStatus | ^ false].
  1487         outStream contents
  1487 	outStream contents
  1488     "
  1488     "
  1489 
  1489 
  1490     "
  1490     "
  1491         |outStream errStream|
  1491 	|outStream errStream|
  1492 
  1492 
  1493         outStream := #[] writeStream.
  1493 	outStream := #[] writeStream.
  1494 
  1494 
  1495         OperatingSystem executeCommand:'cat'
  1495 	OperatingSystem executeCommand:'cat'
  1496                         inputFrom:(ByteArray new:5000000) readStream
  1496 			inputFrom:(ByteArray new:5000000) readStream
  1497                         outputTo:outStream
  1497 			outputTo:outStream
  1498                         errorTo:nil
  1498 			errorTo:nil
  1499                         inDirectory:nil
  1499 			inDirectory:nil
  1500                         lineWise:false
  1500 			lineWise:false
  1501                         onError:[:exitStatus | ^ false].
  1501 			onError:[:exitStatus | ^ false].
  1502         outStream size
  1502 	outStream size
  1503     "
  1503     "
  1504 
  1504 
  1505     "
  1505     "
  1506         |outStream errStream|
  1506 	|outStream errStream|
  1507 
  1507 
  1508         outStream := '' writeStream.
  1508 	outStream := '' writeStream.
  1509 
  1509 
  1510         OperatingSystem executeCommand:'gpg -s --batch --no-tty --passphrase-fd 0 /tmp/passwd'
  1510 	OperatingSystem executeCommand:'gpg -s --batch --no-tty --passphrase-fd 0 /tmp/passwd'
  1511                         inputFrom:'bla' readStream
  1511 			inputFrom:'bla' readStream
  1512                         outputTo:outStream
  1512 			outputTo:outStream
  1513                         errorTo:nil
  1513 			errorTo:nil
  1514                         inDirectory:nil
  1514 			inDirectory:nil
  1515                         lineWise:true
  1515 			lineWise:true
  1516                         onError:[:exitStatus |  false].
  1516 			onError:[:exitStatus |  false].
  1517         outStream contents
  1517 	outStream contents
  1518     "
  1518     "
  1519 
  1519 
  1520     "Modified: / 11-02-2007 / 20:54:39 / cg"
  1520     "Modified: / 11-02-2007 / 20:54:39 / cg"
  1521 !
  1521 !
  1522 
  1522 
  1542      Set lineWise to true, if both error and output is sent to the same stream
  1542      Set lineWise to true, if both error and output is sent to the same stream
  1543      and you don't want lines to be mangled. Set lineWise = false to
  1543      and you don't want lines to be mangled. Set lineWise = false to
  1544      avoid blocking on pipes.
  1544      avoid blocking on pipes.
  1545 
  1545 
  1546      Special for windows:
  1546      Special for windows:
  1547         you can control (have to - sigh) if a window should be shown for the command or not.
  1547 	you can control (have to - sigh) if a window should be shown for the command or not.
  1548         This is the OS's H_SHOWWINDOW argument.
  1548 	This is the OS's H_SHOWWINDOW argument.
  1549         If you pass nil as showWindow-argument, the OS's default is used for the particular
  1549 	If you pass nil as showWindow-argument, the OS's default is used for the particular
  1550         command, which is correct most of the time: i.e. a notepad will open its window, other (non-UI)
  1550 	command, which is correct most of the time: i.e. a notepad will open its window, other (non-UI)
  1551         executables will not.
  1551 	executables will not.
  1552         However, some command-line executables show a window, even if they should not.
  1552 	However, some command-line executables show a window, even if they should not.
  1553         (and also, there seems to be an inconsistency between windows7 and newer windows: in newer,
  1553 	(and also, there seems to be an inconsistency between windows7 and newer windows: in newer,
  1554          a shell command opens a cmd-window, whereas in windows7 it did not)
  1554 	 a shell command opens a cmd-window, whereas in windows7 it did not)
  1555         In this case, pass an explicit false argument to suppress it.
  1555 	In this case, pass an explicit false argument to suppress it.
  1556         This argument is ignored on Unix systems.
  1556 	This argument is ignored on Unix systems.
  1557         See examples below."
  1557 	See examples below."
  1558 
  1558 
  1559     ^ self
  1559     ^ self
  1560         executeCommand:aCommandStringOrArray inputFrom:anInStream outputTo:anOutStream
  1560 	executeCommand:aCommandStringOrArray inputFrom:anInStream outputTo:anOutStream
  1561         errorTo:anErrStream auxFrom:anAuxStream environment:environmentDictionary
  1561 	errorTo:anErrStream auxFrom:anAuxStream environment:environmentDictionary
  1562         inDirectory:dirOrNil lineWise:lineWise newPgrp:true showWindow:showWindowBooleanOrNil onError:aBlock
  1562 	inDirectory:dirOrNil lineWise:lineWise newPgrp:true showWindow:showWindowBooleanOrNil onError:aBlock
  1563 
  1563 
  1564     "
  1564     "
  1565         |outStream errStream|
  1565 	|outStream errStream|
  1566 
  1566 
  1567         outStream := '' writeStream.
  1567 	outStream := '' writeStream.
  1568 
  1568 
  1569         OperatingSystem executeCommand:'ls -l'
  1569 	OperatingSystem executeCommand:'ls -l'
  1570                         inputFrom:'abc' readStream
  1570 			inputFrom:'abc' readStream
  1571                         outputTo:outStream
  1571 			outputTo:outStream
  1572                         errorTo:nil
  1572 			errorTo:nil
  1573                         inDirectory:nil
  1573 			inDirectory:nil
  1574                         lineWise:true
  1574 			lineWise:true
  1575                         onError:[:exitStatus | ^ false].
  1575 			onError:[:exitStatus | ^ false].
  1576         outStream contents
  1576 	outStream contents
  1577     "
  1577     "
  1578 
  1578 
  1579     "
  1579     "
  1580         |outStream errStream|
  1580 	|outStream errStream|
  1581 
  1581 
  1582         outStream := #[] writeStream.
  1582 	outStream := #[] writeStream.
  1583 
  1583 
  1584         OperatingSystem executeCommand:'cat'
  1584 	OperatingSystem executeCommand:'cat'
  1585                         inputFrom:(ByteArray new:5000000) readStream
  1585 			inputFrom:(ByteArray new:5000000) readStream
  1586                         outputTo:outStream
  1586 			outputTo:outStream
  1587                         errorTo:nil
  1587 			errorTo:nil
  1588                         inDirectory:nil
  1588 			inDirectory:nil
  1589                         lineWise:false
  1589 			lineWise:false
  1590                         onError:[:exitStatus | ^ false].
  1590 			onError:[:exitStatus | ^ false].
  1591         outStream size
  1591 	outStream size
  1592     "
  1592     "
  1593 
  1593 
  1594     "
  1594     "
  1595         |outStream errStream|
  1595 	|outStream errStream|
  1596 
  1596 
  1597         outStream := '' writeStream.
  1597 	outStream := '' writeStream.
  1598 
  1598 
  1599         OperatingSystem executeCommand:'gpg -s --batch --no-tty --passphrase-fd 0 /tmp/passwd'
  1599 	OperatingSystem executeCommand:'gpg -s --batch --no-tty --passphrase-fd 0 /tmp/passwd'
  1600                         inputFrom:'bla' readStream
  1600 			inputFrom:'bla' readStream
  1601                         outputTo:outStream
  1601 			outputTo:outStream
  1602                         errorTo:nil
  1602 			errorTo:nil
  1603                         inDirectory:nil
  1603 			inDirectory:nil
  1604                         lineWise:true
  1604 			lineWise:true
  1605                         onError:[:exitStatus |  false].
  1605 			onError:[:exitStatus |  false].
  1606         outStream contents
  1606 	outStream contents
  1607     "
  1607     "
  1608 
  1608 
  1609     "Modified: / 08-11-2016 / 21:33:00 / cg"
  1609     "Modified: / 08-11-2016 / 21:33:00 / cg"
  1610 !
  1610 !
  1611 
  1611 
  1622 	onError:aBlock
  1622 	onError:aBlock
  1623 !
  1623 !
  1624 
  1624 
  1625 executeCommand:aCommandString inputFrom:anInStream outputTo:anOutStream errorTo:anErrStream auxFrom:anAuxStream inDirectory:dirOrNil lineWise:lineWise showWindow:showWindow onError:aBlock
  1625 executeCommand:aCommandString inputFrom:anInStream outputTo:anOutStream errorTo:anErrStream auxFrom:anAuxStream inDirectory:dirOrNil lineWise:lineWise showWindow:showWindow onError:aBlock
  1626     ^ self
  1626     ^ self
  1627         executeCommand:aCommandString
  1627 	executeCommand:aCommandString
  1628         inputFrom:anInStream
  1628 	inputFrom:anInStream
  1629         outputTo:anOutStream
  1629 	outputTo:anOutStream
  1630         errorTo:anErrStream
  1630 	errorTo:anErrStream
  1631         auxFrom:anAuxStream
  1631 	auxFrom:anAuxStream
  1632         environment:nil
  1632 	environment:nil
  1633         inDirectory:dirOrNil
  1633 	inDirectory:dirOrNil
  1634         lineWise:lineWise
  1634 	lineWise:lineWise
  1635         showWindow:showWindow
  1635 	showWindow:showWindow
  1636         onError:aBlock
  1636 	onError:aBlock
  1637 !
  1637 !
  1638 
  1638 
  1639 executeCommand:aCommandString inputFrom:anInStream outputTo:anOutStream errorTo:anErrStream environment:env onError:aBlock
  1639 executeCommand:aCommandString inputFrom:anInStream outputTo:anOutStream errorTo:anErrStream environment:env onError:aBlock
  1640     "execute the unix command specified by the argument, aCommandString.
  1640     "execute the unix command specified by the argument, aCommandString.
  1641      If aCommandString is a String, the commandString is passed to a shell for execution
  1641      If aCommandString is a String, the commandString is passed to a shell for execution
  1713      Return true if successful, the value from aBlock if not.
  1713      Return true if successful, the value from aBlock if not.
  1714      If not successfull, aBlock is called with an OsProcessStatus
  1714      If not successfull, aBlock is called with an OsProcessStatus
  1715      (containing the exit status) as argument."
  1715      (containing the exit status) as argument."
  1716 
  1716 
  1717     ^ self
  1717     ^ self
  1718         executeCommand:aCommandString
  1718 	executeCommand:aCommandString
  1719         inputFrom:anInStream
  1719 	inputFrom:anInStream
  1720         outputTo:anOutStream
  1720 	outputTo:anOutStream
  1721         errorTo:anErrStream
  1721 	errorTo:anErrStream
  1722         auxFrom:nil
  1722 	auxFrom:nil
  1723         environment:env
  1723 	environment:env
  1724         inDirectory:nil
  1724 	inDirectory:nil
  1725         lineWise:false
  1725 	lineWise:false
  1726         showWindow:showWindow
  1726 	showWindow:showWindow
  1727         onError:aBlock
  1727 	onError:aBlock
  1728 
  1728 
  1729     "
  1729     "
  1730         OperatingSystem
  1730 	OperatingSystem
  1731             executeCommand:'dir'
  1731 	    executeCommand:'dir'
  1732             inputFrom:nil
  1732 	    inputFrom:nil
  1733             outputTo:nil
  1733 	    outputTo:nil
  1734             errorTo:nil
  1734 	    errorTo:nil
  1735             onError:[:status | Transcript flash]
  1735 	    onError:[:status | Transcript flash]
  1736 
  1736 
  1737         OperatingSystem
  1737 	OperatingSystem
  1738             executeCommand:'foo'
  1738 	    executeCommand:'foo'
  1739             inputFrom:nil
  1739 	    inputFrom:nil
  1740             outputTo:nil
  1740 	    outputTo:nil
  1741             errorTo:nil
  1741 	    errorTo:nil
  1742             onError:[:status | Transcript flash]
  1742 	    onError:[:status | Transcript flash]
  1743     "
  1743     "
  1744     "
  1744     "
  1745         |outStr errStr|
  1745 	|outStr errStr|
  1746 
  1746 
  1747         outStr := '' writeStream.
  1747 	outStr := '' writeStream.
  1748         errStr := '' writeStream.
  1748 	errStr := '' writeStream.
  1749         OperatingSystem
  1749 	OperatingSystem
  1750             executeCommand:'ls'
  1750 	    executeCommand:'ls'
  1751             inputFrom:nil
  1751 	    inputFrom:nil
  1752             outputTo:outStr
  1752 	    outputTo:outStr
  1753             errorTo:errStr
  1753 	    errorTo:errStr
  1754             onError:[:status | Transcript flash].
  1754 	    onError:[:status | Transcript flash].
  1755         Transcript show:'out:'; showCR:outStr contents.
  1755 	Transcript show:'out:'; showCR:outStr contents.
  1756         Transcript show:'err:'; showCR:errStr contents.
  1756 	Transcript show:'err:'; showCR:errStr contents.
  1757     "
  1757     "
  1758     "
  1758     "
  1759         |outStr errStr|
  1759 	|outStr errStr|
  1760 
  1760 
  1761         outStr := '' writeStream.
  1761 	outStr := '' writeStream.
  1762         errStr := '' writeStream.
  1762 	errStr := '' writeStream.
  1763         OperatingSystem
  1763 	OperatingSystem
  1764             executeCommand:'ls /fooBar'
  1764 	    executeCommand:'ls /fooBar'
  1765             inputFrom:nil
  1765 	    inputFrom:nil
  1766             outputTo:outStr
  1766 	    outputTo:outStr
  1767             errorTo:errStr
  1767 	    errorTo:errStr
  1768             onError:[:status | Transcript flash].
  1768 	    onError:[:status | Transcript flash].
  1769         Transcript show:'out:'; showCR:outStr contents.
  1769 	Transcript show:'out:'; showCR:outStr contents.
  1770         Transcript show:'err:'; showCR:errStr contents.
  1770 	Transcript show:'err:'; showCR:errStr contents.
  1771     "
  1771     "
  1772 
  1772 
  1773     "Modified: / 10.11.1998 / 20:51:39 / cg"
  1773     "Modified: / 10.11.1998 / 20:51:39 / cg"
  1774 !
  1774 !
  1775 
  1775 
  1844      those internal stream(s).
  1844      those internal stream(s).
  1845      Nil stream args will execute the command connected to ST/X's standard input, output or
  1845      Nil stream args will execute the command connected to ST/X's standard input, output or
  1846      error resp. - i.e. usually, i/o will be from/to the terminal"
  1846      error resp. - i.e. usually, i/o will be from/to the terminal"
  1847 
  1847 
  1848     ^ self
  1848     ^ self
  1849         executeCommand:aCommandString
  1849 	executeCommand:aCommandString
  1850         inputFrom:anInStream
  1850 	inputFrom:anInStream
  1851         outputTo:anOutStream
  1851 	outputTo:anOutStream
  1852         errorTo:anErrStream
  1852 	errorTo:anErrStream
  1853         auxFrom:nil
  1853 	auxFrom:nil
  1854         environment:nil
  1854 	environment:nil
  1855         inDirectory:dirOrNil
  1855 	inDirectory:dirOrNil
  1856         lineWise:lineWise
  1856 	lineWise:lineWise
  1857         showWindow:showWindow
  1857 	showWindow:showWindow
  1858         onError:aBlock
  1858 	onError:aBlock
  1859 !
  1859 !
  1860 
  1860 
  1861 executeCommand:aCommandString inputFrom:anInStream outputTo:anOutStream errorTo:anErrStream inDirectory:dirOrNil onError:aBlock
  1861 executeCommand:aCommandString inputFrom:anInStream outputTo:anOutStream errorTo:anErrStream inDirectory:dirOrNil onError:aBlock
  1862     "execute the unix command specified by the argument, aCommandString.
  1862     "execute the unix command specified by the argument, aCommandString.
  1863      If aCommandString is a String, the commandString is passed to a shell for execution
  1863      If aCommandString is a String, the commandString is passed to a shell for execution
  1938      Return true if successful, the value from aBlock if not.
  1938      Return true if successful, the value from aBlock if not.
  1939      If not successfull, aBlock is called with an OsProcessStatus
  1939      If not successfull, aBlock is called with an OsProcessStatus
  1940      (containing the exit status) as argument."
  1940      (containing the exit status) as argument."
  1941 
  1941 
  1942     ^ self
  1942     ^ self
  1943         executeCommand:aCommandString
  1943 	executeCommand:aCommandString
  1944         inputFrom:anInStream
  1944 	inputFrom:anInStream
  1945         outputTo:anOutStream
  1945 	outputTo:anOutStream
  1946         errorTo:anErrStream
  1946 	errorTo:anErrStream
  1947         auxFrom:nil
  1947 	auxFrom:nil
  1948         environment:nil
  1948 	environment:nil
  1949         inDirectory:dir
  1949 	inDirectory:dir
  1950         lineWise:false
  1950 	lineWise:false
  1951         showWindow:showWindow
  1951 	showWindow:showWindow
  1952         onError:aBlock
  1952 	onError:aBlock
  1953 
  1953 
  1954     "
  1954     "
  1955         OperatingSystem
  1955 	OperatingSystem
  1956             executeCommand:'dir'
  1956 	    executeCommand:'dir'
  1957             inputFrom:nil
  1957 	    inputFrom:nil
  1958             outputTo:nil
  1958 	    outputTo:nil
  1959             errorTo:nil
  1959 	    errorTo:nil
  1960             onError:[:status | Transcript flash]
  1960 	    onError:[:status | Transcript flash]
  1961 
  1961 
  1962         OperatingSystem
  1962 	OperatingSystem
  1963             executeCommand:'foo'
  1963 	    executeCommand:'foo'
  1964             inputFrom:nil
  1964 	    inputFrom:nil
  1965             outputTo:nil
  1965 	    outputTo:nil
  1966             errorTo:nil
  1966 	    errorTo:nil
  1967             onError:[:status | Transcript flash]
  1967 	    onError:[:status | Transcript flash]
  1968     "
  1968     "
  1969     "
  1969     "
  1970         |outStr errStr|
  1970 	|outStr errStr|
  1971 
  1971 
  1972         outStr := '' writeStream.
  1972 	outStr := '' writeStream.
  1973         errStr := '' writeStream.
  1973 	errStr := '' writeStream.
  1974         OperatingSystem
  1974 	OperatingSystem
  1975             executeCommand:'ls'
  1975 	    executeCommand:'ls'
  1976             inputFrom:nil
  1976 	    inputFrom:nil
  1977             outputTo:outStr
  1977 	    outputTo:outStr
  1978             errorTo:errStr
  1978 	    errorTo:errStr
  1979             onError:[:status | Transcript flash].
  1979 	    onError:[:status | Transcript flash].
  1980         Transcript show:'out:'; showCR:outStr contents.
  1980 	Transcript show:'out:'; showCR:outStr contents.
  1981         Transcript show:'err:'; showCR:errStr contents.
  1981 	Transcript show:'err:'; showCR:errStr contents.
  1982     "
  1982     "
  1983     "
  1983     "
  1984         |outStr errStr|
  1984 	|outStr errStr|
  1985 
  1985 
  1986         outStr := '' writeStream.
  1986 	outStr := '' writeStream.
  1987         errStr := '' writeStream.
  1987 	errStr := '' writeStream.
  1988         OperatingSystem
  1988 	OperatingSystem
  1989             executeCommand:'ls /fooBar'
  1989 	    executeCommand:'ls /fooBar'
  1990             inputFrom:nil
  1990 	    inputFrom:nil
  1991             outputTo:outStr
  1991 	    outputTo:outStr
  1992             errorTo:errStr
  1992 	    errorTo:errStr
  1993             onError:[:status | Transcript flash].
  1993 	    onError:[:status | Transcript flash].
  1994         Transcript show:'out:'; showCR:outStr contents.
  1994 	Transcript show:'out:'; showCR:outStr contents.
  1995         Transcript show:'err:'; showCR:errStr contents.
  1995 	Transcript show:'err:'; showCR:errStr contents.
  1996     "
  1996     "
  1997 
  1997 
  1998     "Modified: / 10.11.1998 / 20:51:39 / cg"
  1998     "Modified: / 10.11.1998 / 20:51:39 / cg"
  1999 !
  1999 !
  2000 
  2000 
  2075      Return true if successful, the value from aBlock if not.
  2075      Return true if successful, the value from aBlock if not.
  2076      If not successfull, aBlock is called with an OsProcessStatus
  2076      If not successfull, aBlock is called with an OsProcessStatus
  2077      (containing the exit status) as argument."
  2077      (containing the exit status) as argument."
  2078 
  2078 
  2079     ^ self
  2079     ^ self
  2080         executeCommand:aCommandString
  2080 	executeCommand:aCommandString
  2081         inputFrom:anInStream
  2081 	inputFrom:anInStream
  2082         outputTo:anOutStream
  2082 	outputTo:anOutStream
  2083         errorTo:anErrStream
  2083 	errorTo:anErrStream
  2084         auxFrom:nil
  2084 	auxFrom:nil
  2085         environment:nil
  2085 	environment:nil
  2086         inDirectory:nil
  2086 	inDirectory:nil
  2087         lineWise:false
  2087 	lineWise:false
  2088         showWindow:showWindow
  2088 	showWindow:showWindow
  2089         onError:aBlock
  2089 	onError:aBlock
  2090 
  2090 
  2091     "
  2091     "
  2092         OperatingSystem
  2092 	OperatingSystem
  2093             executeCommand:'dir'
  2093 	    executeCommand:'dir'
  2094             inputFrom:nil
  2094 	    inputFrom:nil
  2095             outputTo:nil
  2095 	    outputTo:nil
  2096             errorTo:nil
  2096 	    errorTo:nil
  2097             onError:[:status | Transcript flash]
  2097 	    onError:[:status | Transcript flash]
  2098 
  2098 
  2099         OperatingSystem
  2099 	OperatingSystem
  2100             executeCommand:'foo'
  2100 	    executeCommand:'foo'
  2101             inputFrom:nil
  2101 	    inputFrom:nil
  2102             outputTo:nil
  2102 	    outputTo:nil
  2103             errorTo:nil
  2103 	    errorTo:nil
  2104             onError:[:status | Transcript flash]
  2104 	    onError:[:status | Transcript flash]
  2105     "
  2105     "
  2106     "
  2106     "
  2107         |outStr errStr|
  2107 	|outStr errStr|
  2108 
  2108 
  2109         outStr := '' writeStream.
  2109 	outStr := '' writeStream.
  2110         errStr := '' writeStream.
  2110 	errStr := '' writeStream.
  2111         OperatingSystem
  2111 	OperatingSystem
  2112             executeCommand:'ls'
  2112 	    executeCommand:'ls'
  2113             inputFrom:nil
  2113 	    inputFrom:nil
  2114             outputTo:outStr
  2114 	    outputTo:outStr
  2115             errorTo:errStr
  2115 	    errorTo:errStr
  2116             onError:[:status | Transcript flash].
  2116 	    onError:[:status | Transcript flash].
  2117         Transcript show:'out:'; showCR:outStr contents.
  2117 	Transcript show:'out:'; showCR:outStr contents.
  2118         Transcript show:'err:'; showCR:errStr contents.
  2118 	Transcript show:'err:'; showCR:errStr contents.
  2119     "
  2119     "
  2120     "
  2120     "
  2121         |outStr errStr|
  2121 	|outStr errStr|
  2122 
  2122 
  2123         outStr := '' writeStream.
  2123 	outStr := '' writeStream.
  2124         errStr := '' writeStream.
  2124 	errStr := '' writeStream.
  2125         OperatingSystem
  2125 	OperatingSystem
  2126             executeCommand:'ls /fooBar'
  2126 	    executeCommand:'ls /fooBar'
  2127             inputFrom:nil
  2127 	    inputFrom:nil
  2128             outputTo:outStr
  2128 	    outputTo:outStr
  2129             errorTo:errStr
  2129 	    errorTo:errStr
  2130             onError:[:status | Transcript flash].
  2130 	    onError:[:status | Transcript flash].
  2131         Transcript show:'out:'; showCR:outStr contents.
  2131 	Transcript show:'out:'; showCR:outStr contents.
  2132         Transcript show:'err:'; showCR:errStr contents.
  2132 	Transcript show:'err:'; showCR:errStr contents.
  2133     "
  2133     "
  2134 
  2134 
  2135     "Modified: / 10.11.1998 / 20:51:39 / cg"
  2135     "Modified: / 10.11.1998 / 20:51:39 / cg"
  2136 !
  2136 !
  2137 
  2137 
  2275     "much like #executeCommand:, but changes the current directory
  2275     "much like #executeCommand:, but changes the current directory
  2276      for the command. Since this is OS specific, use this instead of
  2276      for the command. Since this is OS specific, use this instead of
  2277      hardwiring any 'cd ..' command strings into your applictions.
  2277      hardwiring any 'cd ..' command strings into your applictions.
  2278 
  2278 
  2279      Special for windows:
  2279      Special for windows:
  2280         you can control (have to - sigh) if a window should be shown for the command or not.
  2280 	you can control (have to - sigh) if a window should be shown for the command or not.
  2281         This is the OS's H_SHOWWINDOW argument.
  2281 	This is the OS's H_SHOWWINDOW argument.
  2282         If you pass nil as showWindow-argument, the OS's default is used for the particular
  2282 	If you pass nil as showWindow-argument, the OS's default is used for the particular
  2283         command, which is correct most of the time: i.e. a notepad will open its window, other (non-UI)
  2283 	command, which is correct most of the time: i.e. a notepad will open its window, other (non-UI)
  2284         executables will not.
  2284 	executables will not.
  2285         However, some command-line executables show a window, even if they should not.
  2285 	However, some command-line executables show a window, even if they should not.
  2286         (and also, there seems to be an inconsistency between windows7 and newer windows: in newer,
  2286 	(and also, there seems to be an inconsistency between windows7 and newer windows: in newer,
  2287          a shell command opens a cmd-window, whereas in windows7 it did not)
  2287 	 a shell command opens a cmd-window, whereas in windows7 it did not)
  2288         In this case, pass an explicit false argument to suppress it.
  2288 	In this case, pass an explicit false argument to suppress it.
  2289         This argument is ignored on Unix systems.
  2289 	This argument is ignored on Unix systems.
  2290         See examples below."
  2290 	See examples below."
  2291 
  2291 
  2292      ^ self
  2292      ^ self
  2293         executeCommand:aCommandString
  2293 	executeCommand:aCommandString
  2294         inputFrom:nil
  2294 	inputFrom:nil
  2295         outputTo:outStreamOrNil
  2295 	outputTo:outStreamOrNil
  2296         errorTo:errStreamOrNil
  2296 	errorTo:errStreamOrNil
  2297         auxFrom:nil
  2297 	auxFrom:nil
  2298         environment:nil
  2298 	environment:nil
  2299         inDirectory:aDirectory
  2299 	inDirectory:aDirectory
  2300         lineWise:false
  2300 	lineWise:false
  2301         newPgrp:true
  2301 	newPgrp:true
  2302         showWindow:showWindowBooleanOrNil
  2302 	showWindow:showWindowBooleanOrNil
  2303         onError:[:status| false]
  2303 	onError:[:status| false]
  2304 
  2304 
  2305     "
  2305     "
  2306      OperatingSystem executeCommand:'tdump date.obj' inDirectory:'c:\winstx\stx\libbasic\objbc'.
  2306      OperatingSystem executeCommand:'tdump date.obj' inDirectory:'c:\winstx\stx\libbasic\objbc'.
  2307      OperatingSystem executeCommand:'xxdir date.obj' inDirectory:'c:\winstx\stx\libbasic\objbc'.
  2307      OperatingSystem executeCommand:'xxdir date.obj' inDirectory:'c:\winstx\stx\libbasic\objbc'.
  2308      OperatingSystem executeCommand:'dir' inDirectory:'c:\'.
  2308      OperatingSystem executeCommand:'dir' inDirectory:'c:\'.
  2344 executeCommand:aCommandString showWindow:aBooleanOrNil
  2344 executeCommand:aCommandString showWindow:aBooleanOrNil
  2345     "execute the OS command specified by the argument, aCommandString.
  2345     "execute the OS command specified by the argument, aCommandString.
  2346      If aCommandString is a String, the commandString is passed to a shell for execution
  2346      If aCommandString is a String, the commandString is passed to a shell for execution
  2347      - see the description of 'sh -c' in your UNIX manual ('cmd.com' in your MSDOS manual).
  2347      - see the description of 'sh -c' in your UNIX manual ('cmd.com' in your MSDOS manual).
  2348      If aCommandString is an Array, the first element is the command to be executed,
  2348      If aCommandString is an Array, the first element is the command to be executed,
  2349      and the other elements are the arguments to the command. 
  2349      and the other elements are the arguments to the command.
  2350      No shell is invoked in this case.
  2350      No shell is invoked in this case.
  2351      This blocks the current thread until the command has finished.
  2351      This blocks the current thread until the command has finished.
  2352      Return true if successful, false otherwise.
  2352      Return true if successful, false otherwise.
  2353 
  2353 
  2354      Special for windows:
  2354      Special for windows:
  2355         you can control (have to - sigh) if a window should be shown for the command or not.
  2355 	you can control (have to - sigh) if a window should be shown for the command or not.
  2356         This is the OS's H_SHOWWINDOW argument.
  2356 	This is the OS's H_SHOWWINDOW argument.
  2357         If you pass nil as showWindow-argument, the OS's default is used for the particular
  2357 	If you pass nil as showWindow-argument, the OS's default is used for the particular
  2358         command, which is correct most of the time: i.e. a notepad will open its window, other (non-UI)
  2358 	command, which is correct most of the time: i.e. a notepad will open its window, other (non-UI)
  2359         executables will not.
  2359 	executables will not.
  2360         However, some command-line executables show a window, even if they should not.
  2360 	However, some command-line executables show a window, even if they should not.
  2361         (and also, there seems to be an inconsistency between windows7 and newer windows: in newer,
  2361 	(and also, there seems to be an inconsistency between windows7 and newer windows: in newer,
  2362          a shell command opens a cmd-window, whereas in windows7 it did not)
  2362 	 a shell command opens a cmd-window, whereas in windows7 it did not)
  2363         In this case, pass an explicit false argument to suppress it.
  2363 	In this case, pass an explicit false argument to suppress it.
  2364         This argument is ignored on Unix systems.
  2364 	This argument is ignored on Unix systems.
  2365         See examples below.
  2365 	See examples below.
  2366     "
  2366     "
  2367 
  2367 
  2368      ^ self
  2368      ^ self
  2369         executeCommand:aCommandString
  2369 	executeCommand:aCommandString
  2370         inputFrom:nil
  2370 	inputFrom:nil
  2371         outputTo:nil
  2371 	outputTo:nil
  2372         errorTo:nil
  2372 	errorTo:nil
  2373         auxFrom:nil
  2373 	auxFrom:nil
  2374         environment:nil
  2374 	environment:nil
  2375         inDirectory:nil
  2375 	inDirectory:nil
  2376         lineWise:false
  2376 	lineWise:false
  2377         showWindow:aBooleanOrNil
  2377 	showWindow:aBooleanOrNil
  2378         onError:[:status| false]
  2378 	onError:[:status| false]
  2379 
  2379 
  2380     "unix:
  2380     "unix:
  2381 
  2381 
  2382      OperatingSystem executeCommand:'sleep 30'.
  2382      OperatingSystem executeCommand:'sleep 30'.
  2383      OperatingSystem executeCommand:'pwd'.
  2383      OperatingSystem executeCommand:'pwd'.
  2567 
  2567 
  2568     |path|
  2568     |path|
  2569 
  2569 
  2570     path := self pathOfCommand:(self nameOfSTXExecutable).
  2570     path := self pathOfCommand:(self nameOfSTXExecutable).
  2571     path isNil ifTrue:[
  2571     path isNil ifTrue:[
  2572         './stx' asFilename exists ifTrue:[
  2572 	'./stx' asFilename exists ifTrue:[
  2573             path := './stx'
  2573 	    path := './stx'
  2574         ].
  2574 	].
  2575         path isNil ifTrue:[
  2575 	path isNil ifTrue:[
  2576              'OperatingSystem [warning]: cannot figure out my executable''s path' infoPrintCR.
  2576 	     'OperatingSystem [warning]: cannot figure out my executable''s path' infoPrintCR.
  2577         ].
  2577 	].
  2578     ].
  2578     ].
  2579     ^ path
  2579     ^ path
  2580 
  2580 
  2581     "
  2581     "
  2582      OperatingSystem pathOfSTXExecutable
  2582      OperatingSystem pathOfSTXExecutable
  2594      If successful, this method does NOT return and smalltalk is gone.
  2594      If successful, this method does NOT return and smalltalk is gone.
  2595      If not successful, it does return.
  2595      If not successful, it does return.
  2596      Can be used on UNIX with fork or on other systems to chain to another program."
  2596      Can be used on UNIX with fork or on other systems to chain to another program."
  2597 
  2597 
  2598     ^ self
  2598     ^ self
  2599         exec:aCommandPath
  2599 	exec:aCommandPath
  2600         withArguments:argArray
  2600 	withArguments:argArray
  2601         environment:nil
  2601 	environment:nil
  2602         fileDescriptors:#(0 1 2)
  2602 	fileDescriptors:#(0 1 2)
  2603         fork:false
  2603 	fork:false
  2604         newPgrp:false
  2604 	newPgrp:false
  2605         inDirectory:nil
  2605 	inDirectory:nil
  2606         showWindow:false
  2606 	showWindow:false
  2607 
  2607 
  2608     "/ never reached ...
  2608     "/ never reached ...
  2609 
  2609 
  2610     "Modified: / 12.11.1998 / 14:44:26 / cg"
  2610     "Modified: / 12.11.1998 / 14:44:26 / cg"
  2611 !
  2611 !
  2612 
  2612 
  2613 exec:aCommandPath withArguments:argArray environment:env fileDescriptors:fds fork:doFork newPgrp:newGrp inDirectory:aDirectory
  2613 exec:aCommandPath withArguments:argArray environment:env fileDescriptors:fds fork:doFork newPgrp:newGrp inDirectory:aDirectory
  2614     <resource: #obsolete>
  2614     <resource: #obsolete>
  2615     "execute an OS command"
  2615     "execute an OS command"
  2616 
  2616 
  2617     ^ self 
  2617     ^ self
  2618         exec:aCommandPath withArguments:argArray environment:env fileDescriptors:fds fork:doFork 
  2618 	exec:aCommandPath withArguments:argArray environment:env fileDescriptors:fds fork:doFork
  2619         newPgrp:newGrp inDirectory:aDirectory showWindow:false
  2619 	newPgrp:newGrp inDirectory:aDirectory showWindow:false
  2620 
  2620 
  2621     "Created: / 12.11.1998 / 14:46:15 / cg"
  2621     "Created: / 12.11.1998 / 14:46:15 / cg"
  2622 !
  2622 !
  2623 
  2623 
  2624 exec:aCommandPath withArguments:argArray fileDescriptors:fileDescriptors fork:doFork newPgrp:newPgrp inDirectory:aDirectory
  2624 exec:aCommandPath withArguments:argArray fileDescriptors:fileDescriptors fork:doFork newPgrp:newPgrp inDirectory:aDirectory
  2625     <resource: #obsolete>
  2625     <resource: #obsolete>
  2626     ^ self
  2626     ^ self
  2627         exec:aCommandPath
  2627 	exec:aCommandPath
  2628         withArguments:argArray
  2628 	withArguments:argArray
  2629         environment:nil
  2629 	environment:nil
  2630         fileDescriptors:fileDescriptors
  2630 	fileDescriptors:fileDescriptors
  2631         fork:doFork
  2631 	fork:doFork
  2632         newPgrp:newPgrp
  2632 	newPgrp:newPgrp
  2633         inDirectory:aDirectory
  2633 	inDirectory:aDirectory
  2634         showWindow:false
  2634 	showWindow:false
  2635 !
  2635 !
  2636 
  2636 
  2637 exec:aCommandPath withArguments:argArray fork:doFork
  2637 exec:aCommandPath withArguments:argArray fork:doFork
  2638     <resource: #obsolete>
  2638     <resource: #obsolete>
  2639     "execute an OS command without I/O redirection.
  2639     "execute an OS command without I/O redirection.
  2640      The command reads its input and writes its output
  2640      The command reads its input and writes its output
  2641      from/to whatever terminal device ST/X was started
  2641      from/to whatever terminal device ST/X was started
  2642      (typically, the terminal window)"
  2642      (typically, the terminal window)"
  2643 
  2643 
  2644     ^ self
  2644     ^ self
  2645         exec:aCommandPath
  2645 	exec:aCommandPath
  2646         withArguments:argArray
  2646 	withArguments:argArray
  2647         environment:nil
  2647 	environment:nil
  2648         fileDescriptors:#(0 1 2)
  2648 	fileDescriptors:#(0 1 2)
  2649         fork:doFork
  2649 	fork:doFork
  2650         newPgrp:false
  2650 	newPgrp:false
  2651         inDirectory:nil
  2651 	inDirectory:nil
  2652         showWindow:false
  2652 	showWindow:false
  2653     "
  2653     "
  2654      |id|
  2654      |id|
  2655 
  2655 
  2656      id := OperatingSystem fork.
  2656      id := OperatingSystem fork.
  2657      id == 0 ifTrue:[
  2657      id == 0 ifTrue:[
  2658         'I am the child'.
  2658 	'I am the child'.
  2659         OperatingSystem
  2659 	OperatingSystem
  2660             exec:'/bin/ls'
  2660 	    exec:'/bin/ls'
  2661             withArguments:#('ls' '/tmp')
  2661 	    withArguments:#('ls' '/tmp')
  2662             fork:false.
  2662 	    fork:false.
  2663         'not reached'.
  2663 	'not reached'.
  2664      ]
  2664      ]
  2665     "
  2665     "
  2666 
  2666 
  2667     "
  2667     "
  2668      |id|
  2668      |id|
  2669 
  2669 
  2670      id := OperatingSystem fork.
  2670      id := OperatingSystem fork.
  2671      id == 0 ifTrue:[
  2671      id == 0 ifTrue:[
  2672         'I am the child'.
  2672 	'I am the child'.
  2673         OperatingSystem
  2673 	OperatingSystem
  2674             exec:'/bin/sh'
  2674 	    exec:'/bin/sh'
  2675             withArguments:#('sh' '-c' 'sleep 2;echo 1;sleep 2;echo 2')
  2675 	    withArguments:#('sh' '-c' 'sleep 2;echo 1;sleep 2;echo 2')
  2676             fork:false.
  2676 	    fork:false.
  2677         'not reached'.
  2677 	'not reached'.
  2678      ].
  2678      ].
  2679      id printNL.
  2679      id printNL.
  2680      (Delay forSeconds:3.5) wait.
  2680      (Delay forSeconds:3.5) wait.
  2681      'killing ...' printNL.
  2681      'killing ...' printNL.
  2682      OperatingSystem sendSignal:(OperatingSystem sigTERM) to:id.
  2682      OperatingSystem sendSignal:(OperatingSystem sigTERM) to:id.
  2693      The command reads its input and writes its output
  2693      The command reads its input and writes its output
  2694      from/to whatever terminal device ST/X was started
  2694      from/to whatever terminal device ST/X was started
  2695      (typically, the terminal window)"
  2695      (typically, the terminal window)"
  2696 
  2696 
  2697     ^ self
  2697     ^ self
  2698         exec:aCommandPath
  2698 	exec:aCommandPath
  2699         withArguments:argArray
  2699 	withArguments:argArray
  2700         environment:nil
  2700 	environment:nil
  2701         fileDescriptors:#(0 1 2)
  2701 	fileDescriptors:#(0 1 2)
  2702         fork:doFork
  2702 	fork:doFork
  2703         newPgrp:false
  2703 	newPgrp:false
  2704         inDirectory:aDirectory
  2704 	inDirectory:aDirectory
  2705         showWindow:false
  2705 	showWindow:false
  2706     "
  2706     "
  2707      |id|
  2707      |id|
  2708 
  2708 
  2709      id := OperatingSystem fork.
  2709      id := OperatingSystem fork.
  2710      id == 0 ifTrue:[
  2710      id == 0 ifTrue:[
  2711         'I am the child'.
  2711 	'I am the child'.
  2712         OperatingSystem
  2712 	OperatingSystem
  2713             exec:'/bin/ls'
  2713 	    exec:'/bin/ls'
  2714             withArguments:#('ls' '/tmp')
  2714 	    withArguments:#('ls' '/tmp')
  2715             fork:false.
  2715 	    fork:false.
  2716         'not reached'.
  2716 	'not reached'.
  2717      ]
  2717      ]
  2718     "
  2718     "
  2719 
  2719 
  2720     "
  2720     "
  2721      |id|
  2721      |id|
  2722 
  2722 
  2723      id := OperatingSystem fork.
  2723      id := OperatingSystem fork.
  2724      id == 0 ifTrue:[
  2724      id == 0 ifTrue:[
  2725         'I am the child'.
  2725 	'I am the child'.
  2726         OperatingSystem
  2726 	OperatingSystem
  2727             exec:'/bin/sh'
  2727 	    exec:'/bin/sh'
  2728             withArguments:#('sh' '-c' 'sleep 2;echo 1;sleep 2;echo 2')
  2728 	    withArguments:#('sh' '-c' 'sleep 2;echo 1;sleep 2;echo 2')
  2729             fork:false.
  2729 	    fork:false.
  2730         'not reached'.
  2730 	'not reached'.
  2731      ].
  2731      ].
  2732      id printNL.
  2732      id printNL.
  2733      (Delay forSeconds:3.5) wait.
  2733      (Delay forSeconds:3.5) wait.
  2734      'killing ...' printNL.
  2734      'killing ...' printNL.
  2735      OperatingSystem sendSignal:(OperatingSystem sigTERM) to:id.
  2735      OperatingSystem sendSignal:(OperatingSystem sigTERM) to:id.
  2748      If successful, this method does NOT return and smalltalk is gone.
  2748      If successful, this method does NOT return and smalltalk is gone.
  2749      If not successful, it does return.
  2749      If not successful, it does return.
  2750      Can be used on UNIX with fork or on other systems to chain to another program."
  2750      Can be used on UNIX with fork or on other systems to chain to another program."
  2751 
  2751 
  2752     ^ self
  2752     ^ self
  2753         exec:aCommandPath
  2753 	exec:aCommandPath
  2754         withArguments:argArray
  2754 	withArguments:argArray
  2755         environment:nil
  2755 	environment:nil
  2756         fileDescriptors:#(0 1 2)
  2756 	fileDescriptors:#(0 1 2)
  2757         fork:false
  2757 	fork:false
  2758         newPgrp:false
  2758 	newPgrp:false
  2759         inDirectory:nil
  2759 	inDirectory:nil
  2760         showWindow:showWindowBooleanOrNil
  2760 	showWindow:showWindowBooleanOrNil
  2761 
  2761 
  2762     "/ never reached ...
  2762     "/ never reached ...
  2763 
  2763 
  2764     "Modified: / 12.11.1998 / 14:44:26 / cg"
  2764     "Modified: / 12.11.1998 / 14:44:26 / cg"
  2765 !
  2765 !
  2766 
  2766 
  2767 startProcess:aCommandString
  2767 startProcess:aCommandString
  2768     <resource: #obsolete>
  2768     <resource: #obsolete>
  2769 
  2769 
  2770     ^ self 
  2770     ^ self
  2771         startProcess:aCommandString inputFrom:nil outputTo:nil
  2771 	startProcess:aCommandString inputFrom:nil outputTo:nil
  2772         errorTo:nil auxFrom:nil environment:nil 
  2772 	errorTo:nil auxFrom:nil environment:nil
  2773         inDirectory:nil newPgrp:true showWindow:nil
  2773 	inDirectory:nil newPgrp:true showWindow:nil
  2774 
  2774 
  2775     "
  2775     "
  2776      |pid|
  2776      |pid|
  2777 
  2777 
  2778      pid := OperatingSystem startProcess:'sleep 2; echo 1; sleep 2; echo 2'.
  2778      pid := OperatingSystem startProcess:'sleep 2; echo 1; sleep 2; echo 2'.
  2788     "
  2788     "
  2789     "
  2789     "
  2790      |pid|
  2790      |pid|
  2791 
  2791 
  2792      pid := OperatingSystem
  2792      pid := OperatingSystem
  2793                 startProcess:'dir/l'
  2793 		startProcess:'dir/l'
  2794                 inputFrom:nil
  2794 		inputFrom:nil
  2795                 outputTo:Stdout
  2795 		outputTo:Stdout
  2796                 errorTo:nil
  2796 		errorTo:nil
  2797                 inDirectory:nil.
  2797 		inDirectory:nil.
  2798      (Delay forSeconds:2) wait.
  2798      (Delay forSeconds:2) wait.
  2799      OperatingSystem killProcess:pid.
  2799      OperatingSystem killProcess:pid.
  2800     "
  2800     "
  2801 
  2801 
  2802     "Modified: / 21.3.1997 / 10:04:35 / dq"
  2802     "Modified: / 21.3.1997 / 10:04:35 / dq"
  2805 
  2805 
  2806 startProcess:aCommandString inDirectory:aDirectory
  2806 startProcess:aCommandString inDirectory:aDirectory
  2807     <resource: #obsolete>
  2807     <resource: #obsolete>
  2808 
  2808 
  2809     ^ self
  2809     ^ self
  2810         startProcess:aCommandString inputFrom:nil outputTo:nil
  2810 	startProcess:aCommandString inputFrom:nil outputTo:nil
  2811         errorTo:nil auxFrom:nil environment:nil 
  2811 	errorTo:nil auxFrom:nil environment:nil
  2812         inDirectory:aDirectory newPgrp:true showWindow:nil
  2812 	inDirectory:aDirectory newPgrp:true showWindow:nil
  2813     "
  2813     "
  2814      |pid|
  2814      |pid|
  2815 
  2815 
  2816      pid := OperatingSystem startProcess:'sleep 2; echo 1; sleep 2; echo 2'.
  2816      pid := OperatingSystem startProcess:'sleep 2; echo 1; sleep 2; echo 2'.
  2817      (Delay forSeconds:3) wait.
  2817      (Delay forSeconds:3) wait.
  2824 !
  2824 !
  2825 
  2825 
  2826 startProcess:aCommandString inputFrom:anExternalInStream outputTo:anExternalOutStream errorTo:anExternalErrStream
  2826 startProcess:aCommandString inputFrom:anExternalInStream outputTo:anExternalOutStream errorTo:anExternalErrStream
  2827     <resource: #obsolete>
  2827     <resource: #obsolete>
  2828 
  2828 
  2829     ^ self 
  2829     ^ self
  2830         startProcess:aCommandString inputFrom:anExternalInStream outputTo:anExternalOutStream
  2830 	startProcess:aCommandString inputFrom:anExternalInStream outputTo:anExternalOutStream
  2831         errorTo:anExternalErrStream auxFrom:nil environment:nil 
  2831 	errorTo:anExternalErrStream auxFrom:nil environment:nil
  2832         inDirectory:nil newPgrp:true showWindow:nil
  2832 	inDirectory:nil newPgrp:true showWindow:nil
  2833 !
  2833 !
  2834 
  2834 
  2835 startProcess:aCommandString inputFrom:anExternalInStream outputTo:anExternalOutStream
  2835 startProcess:aCommandString inputFrom:anExternalInStream outputTo:anExternalOutStream
  2836     errorTo:anExternalErrStream auxFrom:anExternalAuxStreamOrNil environment:environment inDirectory:dir
  2836     errorTo:anExternalErrStream auxFrom:anExternalAuxStreamOrNil environment:environment inDirectory:dir
  2837     <resource: #obsolete>
  2837     <resource: #obsolete>
  2838 
  2838 
  2839     ^ self 
  2839     ^ self
  2840         startProcess:aCommandString inputFrom:anExternalInStream outputTo:anExternalOutStream
  2840 	startProcess:aCommandString inputFrom:anExternalInStream outputTo:anExternalOutStream
  2841         errorTo:anExternalErrStream auxFrom:anExternalAuxStreamOrNil environment:environment 
  2841 	errorTo:anExternalErrStream auxFrom:anExternalAuxStreamOrNil environment:environment
  2842         inDirectory:dir newPgrp:true showWindow:nil
  2842 	inDirectory:dir newPgrp:true showWindow:nil
  2843 !
  2843 !
  2844 
  2844 
  2845 startProcess:aCommandString inputFrom:anExternalInStream outputTo:anExternalOutStream
  2845 startProcess:aCommandString inputFrom:anExternalInStream outputTo:anExternalOutStream
  2846     errorTo:anExternalErrStream auxFrom:anExternalAuxStreamOrNil environment:environment 
  2846     errorTo:anExternalErrStream auxFrom:anExternalAuxStreamOrNil environment:environment
  2847     inDirectory:dir showWindow:showWindowBooleanOrNil
  2847     inDirectory:dir showWindow:showWindowBooleanOrNil
  2848     <resource: #obsolete>
  2848     <resource: #obsolete>
  2849 
  2849 
  2850     ^ self
  2850     ^ self
  2851         startProcess:aCommandString inputFrom:anExternalInStream outputTo:anExternalOutStream
  2851 	startProcess:aCommandString inputFrom:anExternalInStream outputTo:anExternalOutStream
  2852         errorTo:anExternalErrStream auxFrom:anExternalAuxStreamOrNil environment:environment 
  2852 	errorTo:anExternalErrStream auxFrom:anExternalAuxStreamOrNil environment:environment
  2853         inDirectory:dir newPgrp:true showWindow:showWindowBooleanOrNil
  2853 	inDirectory:dir newPgrp:true showWindow:showWindowBooleanOrNil
  2854 
  2854 
  2855     "Modified: / 08-11-2016 / 21:24:27 / cg"
  2855     "Modified: / 08-11-2016 / 21:24:27 / cg"
  2856 !
  2856 !
  2857 
  2857 
  2858 startProcess:aCommandString inputFrom:anExternalInStream outputTo:anExternalOutStream
  2858 startProcess:aCommandString inputFrom:anExternalInStream outputTo:anExternalOutStream
  2859     errorTo:anExternalErrStream auxFrom:anAuxiliaryStream inDirectory:dir
  2859     errorTo:anExternalErrStream auxFrom:anAuxiliaryStream inDirectory:dir
  2860     <resource: #obsolete>
  2860     <resource: #obsolete>
  2861 
  2861 
  2862     ^ self 
  2862     ^ self
  2863         startProcess:aCommandString inputFrom:anExternalInStream outputTo:anExternalOutStream
  2863 	startProcess:aCommandString inputFrom:anExternalInStream outputTo:anExternalOutStream
  2864         errorTo:anExternalErrStream auxFrom:nil environment:nil
  2864 	errorTo:anExternalErrStream auxFrom:nil environment:nil
  2865         inDirectory:dir newPgrp:true showWindow:nil
  2865 	inDirectory:dir newPgrp:true showWindow:nil
  2866 !
  2866 !
  2867 
  2867 
  2868 startProcess:aCommandString inputFrom:anExternalInStream outputTo:anExternalOutStream errorTo:anExternalErrStream inDirectory:dir
  2868 startProcess:aCommandString inputFrom:anExternalInStream outputTo:anExternalOutStream errorTo:anExternalErrStream inDirectory:dir
  2869     <resource: #obsolete>
  2869     <resource: #obsolete>
  2870 
  2870 
  2871     ^ self
  2871     ^ self
  2872         startProcess:aCommandString inputFrom:anExternalInStream outputTo:anExternalOutStream
  2872 	startProcess:aCommandString inputFrom:anExternalInStream outputTo:anExternalOutStream
  2873         errorTo:anExternalErrStream auxFrom:nil environment:nil 
  2873 	errorTo:anExternalErrStream auxFrom:nil environment:nil
  2874         inDirectory:dir newPgrp:true showWindow:nil
  2874 	inDirectory:dir newPgrp:true showWindow:nil
  2875 ! !
  2875 ! !
  2876 
  2876 
  2877 !AbstractOperatingSystem class methodsFor:'file access'!
  2877 !AbstractOperatingSystem class methodsFor:'file access'!
  2878 
  2878 
  2879 closeFd:anInteger
  2879 closeFd:anInteger
  3007 
  3007 
  3008     |osErrorHolder nextDirName|
  3008     |osErrorHolder nextDirName|
  3009 
  3009 
  3010     self createDirectory:dirName.
  3010     self createDirectory:dirName.
  3011     (self isDirectory:dirName) ifFalse:[
  3011     (self isDirectory:dirName) ifFalse:[
  3012         nextDirName := dirName asFilename directoryName.
  3012 	nextDirName := dirName asFilename directoryName.
  3013         dirName ~= nextDirName ifTrue:[
  3013 	dirName ~= nextDirName ifTrue:[
  3014             osErrorHolder := self recursiveCreateDirectory:nextDirName.
  3014 	    osErrorHolder := self recursiveCreateDirectory:nextDirName.
  3015             osErrorHolder notNil ifTrue:[ 
  3015 	    osErrorHolder notNil ifTrue:[
  3016                 ^ osErrorHolder.
  3016 		^ osErrorHolder.
  3017             ].
  3017 	    ].
  3018         ].
  3018 	].
  3019         ^ self createDirectory:dirName.
  3019 	^ self createDirectory:dirName.
  3020     ].
  3020     ].
  3021     ^ nil.
  3021     ^ nil.
  3022 
  3022 
  3023     "
  3023     "
  3024      OperatingSystem recursiveCreateDirectory:'foo/bar/baz'
  3024      OperatingSystem recursiveCreateDirectory:'foo/bar/baz'
  3367      or throw an error if given file is not a valid an executable now
  3367      or throw an error if given file is not a valid an executable now
  3368      shared object.
  3368      shared object.
  3369 
  3369 
  3370      The info object returned is OS-specific, however it responds to at
  3370      The info object returned is OS-specific, however it responds to at
  3371      least
  3371      least
  3372         #isFor32BitArchitecture
  3372 	#isFor32BitArchitecture
  3373         #isFor64BitArchitecture ... returns true, if the given object is for
  3373 	#isFor64BitArchitecture ... returns true, if the given object is for
  3374                                      32bit, 64bit architecture respectively
  3374 				     32bit, 64bit architecture respectively
  3375     "
  3375     "
  3376     ^ self subclassResponsibility
  3376     ^ self subclassResponsibility
  3377 
  3377 
  3378     "Modified: / 26-03-2015 / 11:28:23 / Jan Vrany <jan.vrany@fit.cvut.cz>"
  3378     "Modified: / 26-03-2015 / 11:28:23 / Jan Vrany <jan.vrany@fit.cvut.cz>"
  3379 !
  3379 !
  4198 
  4198 
  4199 !AbstractOperatingSystem class methodsFor:'os queries'!
  4199 !AbstractOperatingSystem class methodsFor:'os queries'!
  4200 
  4200 
  4201 getCCDefine
  4201 getCCDefine
  4202     <resource: #obsolete>
  4202     <resource: #obsolete>
  4203     
  4203 
  4204     "return a string which was used to identify the C-Compiler used
  4204     "return a string which was used to identify the C-Compiler used
  4205      when STX was compiled, and which should be passed down when compiling methods.
  4205      when STX was compiled, and which should be passed down when compiling methods.
  4206      For example, on linux, this is '__GNUC__';
  4206      For example, on linux, this is '__GNUC__';
  4207      on windows, this could be '__VISUALC__', '__BORLANDC__' or '__MINGW__'"
  4207      on windows, this could be '__VISUALC__', '__BORLANDC__' or '__MINGW__'"
  4208 
  4208 
  4433     self subclassResponsibility
  4433     self subclassResponsibility
  4434 !
  4434 !
  4435 
  4435 
  4436 getNetworkMACAddresses
  4436 getNetworkMACAddresses
  4437     "return a dictionary with key:name of interface and
  4437     "return a dictionary with key:name of interface and
  4438                             value:the MAC address for each interface"
  4438 			    value:the MAC address for each interface"
  4439 
  4439 
  4440     self subclassResponsibility
  4440     self subclassResponsibility
  4441 !
  4441 !
  4442 
  4442 
  4443 getNetworkMACAddressesForIf:ifName
  4443 getNetworkMACAddressesForIf:ifName
  4454     self subclassResponsibility
  4454     self subclassResponsibility
  4455 !
  4455 !
  4456 
  4456 
  4457 getOSDefine
  4457 getOSDefine
  4458     <resource: #obsolete>
  4458     <resource: #obsolete>
  4459     
  4459 
  4460     "return a string which was used to identify this machine when stx was
  4460     "return a string which was used to identify this machine when stx was
  4461      compiled, and which should be passed down when compiling methods.
  4461      compiled, and which should be passed down when compiling methods.
  4462      For example, on linux, this is '-D__linux__'."
  4462      For example, on linux, this is '-D__linux__'."
  4463 
  4463 
  4464     self obsoleteMethodWarning.
  4464     self obsoleteMethodWarning.
  4624     "
  4624     "
  4625 !
  4625 !
  4626 
  4626 
  4627 getPlatformDefine
  4627 getPlatformDefine
  4628     <resource: #obsolete>
  4628     <resource: #obsolete>
  4629     
  4629 
  4630     "return a string which defines the platform,
  4630     "return a string which defines the platform,
  4631      and which should be passed down when compiling methods.
  4631      and which should be passed down when compiling methods.
  4632      For example, on all unices, this is '-DUNIX'."
  4632      For example, on all unices, this is '-DUNIX'."
  4633 
  4633 
  4634 %{  /* NOCONTEXT */
  4634 %{  /* NOCONTEXT */
  5181     packagePath add:('.' "Filename currentDirectory pathName").
  5181     packagePath add:('.' "Filename currentDirectory pathName").
  5182 
  5182 
  5183     "/ accept the fact that sometimes, we cannot figure out, where I im
  5183     "/ accept the fact that sometimes, we cannot figure out, where I im
  5184     execPath := self pathOfSTXExecutable.
  5184     execPath := self pathOfSTXExecutable.
  5185     execPath notNil ifTrue:[
  5185     execPath notNil ifTrue:[
  5186         "/
  5186 	"/
  5187         "/ the executable's directory:
  5187 	"/ the executable's directory:
  5188         "/      (/opt/stx/bin/stx -> /opt/stx/bin)
  5188 	"/      (/opt/stx/bin/stx -> /opt/stx/bin)
  5189         "/
  5189 	"/
  5190         appDir := execPath asFilename directory.
  5190 	appDir := execPath asFilename directory.
  5191         dirName := appDir pathName.
  5191 	dirName := appDir pathName.
  5192         (packagePath includes:dirName) ifFalse:[
  5192 	(packagePath includes:dirName) ifFalse:[
  5193             packagePath add:dirName.
  5193 	    packagePath add:dirName.
  5194         ].
  5194 	].
  5195 
  5195 
  5196         "/
  5196 	"/
  5197         "/ the executable's parent directory:
  5197 	"/ the executable's parent directory:
  5198         "/      (/opt/stx/bin/stx -> /opt/stx)
  5198 	"/      (/opt/stx/bin/stx -> /opt/stx)
  5199         "/
  5199 	"/
  5200         appDir := appDir directory.
  5200 	appDir := appDir directory.
  5201         dirName := appDir pathName.
  5201 	dirName := appDir pathName.
  5202         (packagePath includes:dirName) ifFalse:[
  5202 	(packagePath includes:dirName) ifFalse:[
  5203             packagePath add:dirName.
  5203 	    packagePath add:dirName.
  5204         ].
  5204 	].
  5205     ].
  5205     ].
  5206 
  5206 
  5207     homeDirName := OperatingSystem getHomeDirectory.
  5207     homeDirName := OperatingSystem getHomeDirectory.
  5208     homeDirName notNil ifTrue:[
  5208     homeDirName notNil ifTrue:[
  5209         "/
  5209 	"/
  5210         "/ a users private smalltalk directory in its home (login) directory:
  5210 	"/ a users private smalltalk directory in its home (login) directory:
  5211         "/      $HOME/.smalltalk/packages    or $HOME\smalltalk\packages
  5211 	"/      $HOME/.smalltalk/packages    or $HOME\smalltalk\packages
  5212         "/
  5212 	"/
  5213         OperatingSystem isUNIXlike ifTrue:[
  5213 	OperatingSystem isUNIXlike ifTrue:[
  5214             priv := '.smalltalk'.
  5214 	    priv := '.smalltalk'.
  5215         ] ifFalse:[
  5215 	] ifFalse:[
  5216             priv := 'smalltalk'.
  5216 	    priv := 'smalltalk'.
  5217         ].
  5217 	].
  5218         userPrivateSTXDir := homeDirName asFilename / priv.
  5218 	userPrivateSTXDir := homeDirName asFilename / priv.
  5219         (userPrivateSTXDir isDirectory) ifTrue:[
  5219 	(userPrivateSTXDir isDirectory) ifTrue:[
  5220             dirName :=  userPrivateSTXDir pathName.
  5220 	    dirName :=  userPrivateSTXDir pathName.
  5221             (packagePath includes:dirName) ifFalse:[
  5221 	    (packagePath includes:dirName) ifFalse:[
  5222                 packagePath add:dirName
  5222 		packagePath add:dirName
  5223             ]
  5223 	    ]
  5224         ].
  5224 	].
  5225     ].
  5225     ].
  5226 
  5226 
  5227     "/
  5227     "/
  5228     "/ STX_TOPDIR from the environment:
  5228     "/ STX_TOPDIR from the environment:
  5229     "/      $STX_TOPDIR/packages
  5229     "/      $STX_TOPDIR/packages
  5230     "/
  5230     "/
  5231     topDirName := OperatingSystem getEnvironment:'STX_TOPDIR'.
  5231     topDirName := OperatingSystem getEnvironment:'STX_TOPDIR'.
  5232     topDirName notNil ifTrue:[
  5232     topDirName notNil ifTrue:[
  5233         (packagePath includes:topDirName) ifFalse:[
  5233 	(packagePath includes:topDirName) ifFalse:[
  5234             packagePath add:topDirName
  5234 	    packagePath add:topDirName
  5235         ].
  5235 	].
  5236     ].
  5236     ].
  5237 
  5237 
  5238     packagePath := packagePath 
  5238     packagePath := packagePath
  5239                     collect:[:each | 
  5239 		    collect:[:each |
  5240                         |p|
  5240 			|p|
  5241                         
  5241 
  5242                         (p := each asFilename / 'packages') exists ifTrue:[
  5242 			(p := each asFilename / 'packages') exists ifTrue:[
  5243                             p pathName
  5243 			    p pathName
  5244                         ] ifFalse:[
  5244 			] ifFalse:[
  5245                             (p := each asFilename / 'Packages') exists ifTrue:[
  5245 			    (p := each asFilename / 'Packages') exists ifTrue:[
  5246                                 p pathName
  5246 				p pathName
  5247                             ] ifFalse:[
  5247 			    ] ifFalse:[
  5248                                 nil
  5248 				nil
  5249                             ].    
  5249 			    ].
  5250                         ].    
  5250 			].
  5251                     ]
  5251 		    ]
  5252                     thenSelect:[:each | each notNil].
  5252 		    thenSelect:[:each | each notNil].
  5253 
  5253 
  5254     "
  5254     "
  5255      unconditionally prepend all directories from $STX_PACKAGEPATH
  5255      unconditionally prepend all directories from $STX_PACKAGEPATH
  5256     "
  5256     "
  5257     (dirName := OperatingSystem getEnvironment:'STX_PACKAGEPATH') notNil ifTrue:[
  5257     (dirName := OperatingSystem getEnvironment:'STX_PACKAGEPATH') notNil ifTrue:[
  5258         dirName := dirName asCollectionOfSubstringsSeparatedBy:$:.
  5258 	dirName := dirName asCollectionOfSubstringsSeparatedBy:$:.
  5259         dirName reverseDo:[:eachDirectoryName|
  5259 	dirName reverseDo:[:eachDirectoryName|
  5260             (packagePath includes:eachDirectoryName) ifFalse:[
  5260 	    (packagePath includes:eachDirectoryName) ifFalse:[
  5261                 packagePath addFirst:eachDirectoryName.
  5261 		packagePath addFirst:eachDirectoryName.
  5262             ].
  5262 	    ].
  5263         ].
  5263 	].
  5264     ].
  5264     ].
  5265 
  5265 
  5266 false ifTrue:[
  5266 false ifTrue:[
  5267     appDir notNil ifTrue:[
  5267     appDir notNil ifTrue:[
  5268         "maybe the sources are kept in a central place..."
  5268 	"maybe the sources are kept in a central place..."
  5269         (appDir / 'source') isDirectory ifTrue:[
  5269 	(appDir / 'source') isDirectory ifTrue:[
  5270             packagePath add:(appDir / 'source') pathName.
  5270 	    packagePath add:(appDir / 'source') pathName.
  5271         ].
  5271 	].
  5272     ].
  5272     ].
  5273 ].
  5273 ].
  5274 
  5274 
  5275     "maybe we are running in the build environment:  XXX/stx    /projects /smalltalk
  5275     "maybe we are running in the build environment:  XXX/stx    /projects /smalltalk
  5276                                                 or:  XXX/exept  /expecco  /application
  5276 						or:  XXX/exept  /expecco  /application
  5277      - if XXX/stx/libbasic exists, add XXX to the package path"
  5277      - if XXX/stx/libbasic exists, add XXX to the package path"
  5278 false ifTrue:[
  5278 false ifTrue:[
  5279     topDirName isNil ifTrue:[
  5279     topDirName isNil ifTrue:[
  5280         "appdir is now: projects"
  5280 	"appdir is now: projects"
  5281         appDir := appDir directory directory.
  5281 	appDir := appDir directory directory.
  5282         (appDir / 'stx' / 'libbasic') isDirectory ifTrue:[
  5282 	(appDir / 'stx' / 'libbasic') isDirectory ifTrue:[
  5283             appDir pathName = homeDirName ifTrue:[
  5283 	    appDir pathName = homeDirName ifTrue:[
  5284                 "but take care, it may be directly in the home directory"
  5284 		"but take care, it may be directly in the home directory"
  5285                 appDir := appDir / 'stx'.
  5285 		appDir := appDir / 'stx'.
  5286             ].
  5286 	    ].
  5287             packagePath add:appDir pathName.
  5287 	    packagePath add:appDir pathName.
  5288         ].
  5288 	].
  5289     ].
  5289     ].
  5290 ].
  5290 ].
  5291     ^ packagePath
  5291     ^ packagePath
  5292 
  5292 
  5293     "
  5293     "
  5774 #ifdef AF_PACKET
  5774 #ifdef AF_PACKET
  5775 	case AF_PACKET:
  5775 	case AF_PACKET:
  5776 	    domainSymbol = @symbol(AF_PACKET);
  5776 	    domainSymbol = @symbol(AF_PACKET);
  5777 	    break;
  5777 	    break;
  5778 #endif
  5778 #endif
       
  5779 #ifdef AF_LINK
       
  5780 # if AF_LINK != AF_PACKET
       
  5781 	case AF_LINK:
       
  5782 	    domainSymbol = @symbol(AF_LINK);
       
  5783 	    break;
       
  5784 # endif
       
  5785 #endif
  5779 #ifdef AF_ASH
  5786 #ifdef AF_ASH
  5780 	case AF_ASH:
  5787 	case AF_ASH:
  5781 	    domainSymbol = @symbol(AF_ASH);
  5788 	    domainSymbol = @symbol(AF_ASH);
  5782 	    break;
  5789 	    break;
  5783 #endif
  5790 #endif
  6230 		break;
  6237 		break;
  6231 #endif
  6238 #endif
  6232 #ifdef WANT__AF_ISDN
  6239 #ifdef WANT__AF_ISDN
  6233 	    case AF_ISDN:
  6240 	    case AF_ISDN:
  6234 		socketSize = __mkSmallInteger( sizeof(struct sockaddr_isdn) );
  6241 		socketSize = __mkSmallInteger( sizeof(struct sockaddr_isdn) );
       
  6242 		break;
       
  6243 #endif
       
  6244 #ifdef WANT__AF_PACKET
       
  6245 	    case AF_PACKET:
       
  6246 		socketSize = __mkSmallInteger( sizeof(struct sockaddr_ll) );
       
  6247 		break;
       
  6248 #endif
       
  6249 #ifdef WANT__AF_LINK
       
  6250 	    case AF_LINK:
       
  6251 		socketSize = __mkSmallInteger( sizeof(struct sockaddr_dl) );
  6235 		break;
  6252 		break;
  6236 #endif
  6253 #endif
  6237 #ifdef WANT__AF_SYSTEM
  6254 #ifdef WANT__AF_SYSTEM
  6238 	    case AF_SYSTEM:
  6255 	    case AF_SYSTEM:
  6239 		socketSize = __mkSmallInteger( sizeof(struct sockaddr_sys) );
  6256 		socketSize = __mkSmallInteger( sizeof(struct sockaddr_sys) );
  6389 	#AF_HYLINK
  6406 	#AF_HYLINK
  6390 	#AF_FIREFOX
  6407 	#AF_FIREFOX
  6391 	#AF_CLUSTER
  6408 	#AF_CLUSTER
  6392 	#AF_12844
  6409 	#AF_12844
  6393 	#AF_NETDES
  6410 	#AF_NETDES
       
  6411 	#AF_PACKET
       
  6412 	#AF_LINK
  6394        ) select:[:sym | (AbstractOperatingSystem domainCodeOf:sym) isInteger ]
  6413        ) select:[:sym | (AbstractOperatingSystem domainCodeOf:sym) isInteger ]
  6395 
  6414 
  6396     "
  6415     "
  6397      AbstractOperatingSystem supportedProtocolFamilies
  6416      AbstractOperatingSystem supportedProtocolFamilies
  6398     "
  6417     "
  6625     "get a CPU specific cycle counter value.
  6644     "get a CPU specific cycle counter value.
  6626      Can be used for exact timing & performance measurements.
  6645      Can be used for exact timing & performance measurements.
  6627      Notice, that the # of cycles has to be multiplied by the cycle time (1/cpu-frequency).
  6646      Notice, that the # of cycles has to be multiplied by the cycle time (1/cpu-frequency).
  6628 
  6647 
  6629      For x86:
  6648      For x86:
  6630         the CPU cycle count register value is returned (RDTSC instruction).
  6649 	the CPU cycle count register value is returned (RDTSC instruction).
  6631         answer 0 if RDTSC instruction is not supported (which is unlikely, nowadays).
  6650 	answer 0 if RDTSC instruction is not supported (which is unlikely, nowadays).
  6632      For others:
  6651      For others:
  6633         answer 0"
  6652 	answer 0"
  6634 
  6653 
  6635 %{  /* NOCONTEXT */
  6654 %{  /* NOCONTEXT */
  6636     unsigned INT low, high;
  6655     unsigned INT low, high;
  6637 
  6656 
  6638 #if defined(__x86_64__) && (defined(__GNUC__) || defined(__CLANG__) || defined(__MINGW64__))
  6657 #if defined(__x86_64__) && (defined(__GNUC__) || defined(__CLANG__) || defined(__MINGW64__))
  6689      Since this value is wrapping around in regular intervals, this can only be used for
  6708      Since this value is wrapping around in regular intervals, this can only be used for
  6690      short relative time deltas.
  6709      short relative time deltas.
  6691      Use the millisecondTimeXXX:-methods to compare and add time deltas - these know about the wrap.
  6710      Use the millisecondTimeXXX:-methods to compare and add time deltas - these know about the wrap.
  6692 
  6711 
  6693      BAD DESIGN:
  6712      BAD DESIGN:
  6694         This should be changed to return some instance of RelativeTime,
  6713 	This should be changed to return some instance of RelativeTime,
  6695         and these computations moved there.
  6714 	and these computations moved there.
  6696 
  6715 
  6697      Do not use this method in application code since it is an internal (private)
  6716      Do not use this method in application code since it is an internal (private)
  6698      interface. For compatibility with ST-80, use Time millisecondClockValue.
  6717      interface. For compatibility with ST-80, use Time millisecondClockValue.
  6699     "
  6718     "
  6700 
  6719 
  6755      (such as returned getMillisecondTime) which wrap at 16r1FFFFFFF.
  6774      (such as returned getMillisecondTime) which wrap at 16r1FFFFFFF.
  6756 
  6775 
  6757      This should really be moved to some RelativeTime class."
  6776      This should really be moved to some RelativeTime class."
  6758 
  6777 
  6759     (msTime1 > msTime2) ifTrue:[
  6778     (msTime1 > msTime2) ifTrue:[
  6760         ^ (msTime1 - msTime2) <= (SmallInteger maxVal // 4).
  6779 	^ (msTime1 - msTime2) <= (SmallInteger maxVal // 4).
  6761     ] ifFalse:[
  6780     ] ifFalse:[
  6762         ^ (msTime2 - msTime1) > ((SmallInteger maxVal // 4) + 1)
  6781 	^ (msTime2 - msTime1) > ((SmallInteger maxVal // 4) + 1)
  6763     ].
  6782     ].
  6764 !
  6783 !
  6765 
  6784 
  6766 millisecondTimeAdd:msTime1 and:msTime2
  6785 millisecondTimeAdd:msTime1 and:msTime2
  6767     "Add two millisecond times (such as returned getMillisecondTime).
  6786     "Add two millisecond times (such as returned getMillisecondTime).
  6772 
  6791 
  6773     |sum|
  6792     |sum|
  6774 
  6793 
  6775     sum := msTime1 + msTime2.
  6794     sum := msTime1 + msTime2.
  6776     (sum > (SmallInteger maxVal // 2)) ifTrue:[
  6795     (sum > (SmallInteger maxVal // 2)) ifTrue:[
  6777         self assert:(sum <= SmallInteger maxVal) message:'overflow in timer computation'.
  6796 	self assert:(sum <= SmallInteger maxVal) message:'overflow in timer computation'.
  6778         ^ sum - (SmallInteger maxVal // 2 + 1).
  6797 	^ sum - (SmallInteger maxVal // 2 + 1).
  6779     ].
  6798     ].
  6780     (sum < 0) ifTrue:[^ sum + (SmallInteger maxVal // 2 + 1)].
  6799     (sum < 0) ifTrue:[^ sum + (SmallInteger maxVal // 2 + 1)].
  6781     ^ sum
  6800     ^ sum
  6782 !
  6801 !
  6783 
  6802 
  6794     |diff|
  6813     |diff|
  6795 
  6814 
  6796     diff := msTime1 - msTime2.
  6815     diff := msTime1 - msTime2.
  6797 
  6816 
  6798     diff < (SmallInteger maxVal // -4) ifTrue:[
  6817     diff < (SmallInteger maxVal // -4) ifTrue:[
  6799         ^ diff + (SmallInteger maxVal // 2) + 1.
  6818 	^ diff + (SmallInteger maxVal // 2) + 1.
  6800     ].
  6819     ].
  6801 
  6820 
  6802     diff <= (SmallInteger maxVal // 4) ifTrue:[
  6821     diff <= (SmallInteger maxVal // 4) ifTrue:[
  6803         ^ diff.
  6822 	^ diff.
  6804     ] ifFalse:[
  6823     ] ifFalse:[
  6805         ^ diff - (SmallInteger maxVal // 2 + 1).
  6824 	^ diff - (SmallInteger maxVal // 2 + 1).
  6806     ].
  6825     ].
  6807 
  6826 
  6808 
  6827 
  6809     "
  6828     "
  6810      OperatingSystem millisecondTimeAdd:16r0FFFFFFF and:1
  6829      OperatingSystem millisecondTimeAdd:16r0FFFFFFF and:1
  7059      This is the login name, not the fullName."
  7078      This is the login name, not the fullName."
  7060 
  7079 
  7061     "/ fallBack dummy
  7080     "/ fallBack dummy
  7062 
  7081 
  7063     aNumber == self getUserID ifTrue:[
  7082     aNumber == self getUserID ifTrue:[
  7064         ^ self getLoginName
  7083 	^ self getLoginName
  7065     ].
  7084     ].
  7066 
  7085 
  7067     ^ '? (' , aNumber printString , ')'
  7086     ^ '? (' , aNumber printString , ')'
  7068 
  7087 
  7069     "
  7088     "