--- a/AbstractOperatingSystem.st Wed Oct 06 14:38:06 1999 +0200
+++ b/AbstractOperatingSystem.st Wed Oct 06 14:59:16 1999 +0200
@@ -1,6 +1,6 @@
"
COPYRIGHT (c) 1988 by Claus Gittinger
- All Rights Reserved
+ All Rights Reserved
This software is furnished under a license and may be used
only in accordance with the terms of that license and with the
@@ -11,12 +11,12 @@
"
Object subclass:#AbstractOperatingSystem
- instanceVariableNames:''
- classVariableNames:'ConcreteClass LastErrorNumber LocaleInfo OSSignals PipeFailed
- ErrorSignal AccessDeniedErrorSignal FileNotFoundErrorSignal
- InvalidArgumentsSignal UnsupportedOperationSignal'
- poolDictionaries:''
- category:'System-Support'
+ instanceVariableNames:''
+ classVariableNames:'ConcreteClass LastErrorNumber LocaleInfo OSSignals PipeFailed
+ ErrorSignal AccessDeniedErrorSignal FileNotFoundErrorSignal
+ InvalidArgumentsSignal UnsupportedOperationSignal'
+ poolDictionaries:''
+ category:'System-Support'
!
!AbstractOperatingSystem class methodsFor:'documentation'!
@@ -24,7 +24,7 @@
copyright
"
COPYRIGHT (c) 1988 by Claus Gittinger
- All Rights Reserved
+ All Rights Reserved
This software is furnished under a license and may be used
only in accordance with the terms of that license and with the
@@ -43,108 +43,108 @@
less performant) are implemented here.
[Class variables:]
- ConcreteClass <Class> the real OS class
-
- LocaleInfo <Dictionary> if non nil, that is taken instead of the operating
- systems locale definitions (allows for overwriting
- these, or provide a compatible info on systems which do
- not support locales)
-
- LastErrorNumber <Integer> the last value of errno
-
- OSSignals <Array> Array of signals to be raised for corresponding
- OperatingSystem signals.
-
- PipeFailed <Boolean> set if a fork (or popen) has failed;
- ST/X will avoid doing more forks/popens
- if this flag is set, for a slightly
- smoother operation.
-
- ErrorSignal <Signal> Parentsignal of all OS error signals.
- not directly raised.
-
- AccessDeniedErrorSignal misc concrete error reporting signals
- FileNotFoundErrorSignal
- UnsupportedOperationSignal
- InvalidArgumentsSignal
+ ConcreteClass <Class> the real OS class
+
+ LocaleInfo <Dictionary> if non nil, that is taken instead of the operating
+ systems locale definitions (allows for overwriting
+ these, or provide a compatible info on systems which do
+ not support locales)
+
+ LastErrorNumber <Integer> the last value of errno
+
+ OSSignals <Array> Array of signals to be raised for corresponding
+ OperatingSystem signals.
+
+ PipeFailed <Boolean> set if a fork (or popen) has failed;
+ ST/X will avoid doing more forks/popens
+ if this flag is set, for a slightly
+ smoother operation.
+
+ ErrorSignal <Signal> Parentsignal of all OS error signals.
+ not directly raised.
+
+ AccessDeniedErrorSignal misc concrete error reporting signals
+ FileNotFoundErrorSignal
+ UnsupportedOperationSignal
+ InvalidArgumentsSignal
[author:]
- Claus Gittinger
+ Claus Gittinger
[see also:]
- OSProcessStatus
- Filename Date Time
- ExternalStream FileStream PipeStream Socket
+ OSProcessStatus
+ Filename Date Time
+ ExternalStream FileStream PipeStream Socket
"
!
examples
"
various queries
- [exBegin]
+ [exBegin]
Transcript
- showCR:'hello ' , (OperatingSystem getLoginName)
- [exEnd]
-
- [exBegin]
+ showCR:'hello ' , (OperatingSystem getLoginName)
+ [exEnd]
+
+ [exBegin]
OperatingSystem isUNIXlike ifTrue:[
- Transcript showCR:'this is some UNIX-like OS'
+ Transcript showCR:'this is some UNIX-like OS'
] ifFalse:[
- Transcript showCR:'this OS is not UNIX-like'
+ Transcript showCR:'this OS is not UNIX-like'
]
- [exEnd]
-
- [exBegin]
+ [exEnd]
+
+ [exBegin]
Transcript
- showCR:'this machine is called ' , OperatingSystem getHostName
- [exEnd]
-
- [exBegin]
+ showCR:'this machine is called ' , OperatingSystem getHostName
+ [exEnd]
+
+ [exBegin]
Transcript
- showCR:('this machine is in the '
- , OperatingSystem getDomainName
- , ' domain')
- [exEnd]
-
- [exBegin]
+ showCR:('this machine is in the '
+ , OperatingSystem getDomainName
+ , ' domain')
+ [exEnd]
+
+ [exBegin]
Transcript
- showCR:('this machine''s CPU is a '
- , OperatingSystem getCPUType
- )
- [exEnd]
-
- [exBegin]
+ showCR:('this machine''s CPU is a '
+ , OperatingSystem getCPUType
+ )
+ [exEnd]
+
+ [exBegin]
Transcript showCR:'executing ls command ...'.
OperatingSystem executeCommand:'ls'.
Transcript showCR:'... done.'.
- [exEnd]
+ [exEnd]
locking a file
(should be executed on two running smalltalks - not in two threads):
- [exBegin]
+ [exBegin]
|f|
f := 'testFile' asFilename readWriteStream.
10 timesRepeat:[
- 'about to lock ...' printCR.
- [
- OperatingSystem
- lockFD:(f fileDescriptor)
- shared:false
- blocking:false
- ] whileFalse:[
- 'process ' print. OperatingSystem getProcessId print. ' is waiting' printCR.
- Delay waitForSeconds:1
- ].
- 'LOCKED ...' printCR.
- Delay waitForSeconds:10.
- 'unlock ...' printCR.
- (OperatingSystem
- unlockFD:(f fileDescriptor)) printCR.
- Delay waitForSeconds:3.
+ 'about to lock ...' printCR.
+ [
+ OperatingSystem
+ lockFD:(f fileDescriptor)
+ shared:false
+ blocking:false
+ ] whileFalse:[
+ 'process ' print. OperatingSystem getProcessId print. ' is waiting' printCR.
+ Delay waitForSeconds:1
+ ].
+ 'LOCKED ...' printCR.
+ Delay waitForSeconds:10.
+ 'unlock ...' printCR.
+ (OperatingSystem
+ unlockFD:(f fileDescriptor)) printCR.
+ Delay waitForSeconds:3.
]
- [exBegin]
+ [exBegin]
"
! !
@@ -156,25 +156,25 @@
self initializeConcreteClass.
ErrorSignal isNil ifTrue:[
- ErrorSignal := Object errorSignal newSignalMayProceed:true.
- ErrorSignal nameClass:self message:#errorSignal.
- ErrorSignal notifierString:'OS error encountered'.
-
- AccessDeniedErrorSignal := ErrorSignal newSignalMayProceed:true.
- AccessDeniedErrorSignal nameClass:self message:#accessDeniedError.
- AccessDeniedErrorSignal notifierString:'OS access denied'.
-
- FileNotFoundErrorSignal := ErrorSignal newSignalMayProceed:true.
- FileNotFoundErrorSignal nameClass:self message:#fileNotFoundErrorSignal.
- FileNotFoundErrorSignal notifierString:'OS file not found'.
-
- InvalidArgumentsSignal := ErrorSignal newSignalMayProceed:true.
- InvalidArgumentsSignal nameClass:self message:#invalidArgumentsSignal.
- InvalidArgumentsSignal notifierString:'bad arg to OS call'.
-
- UnsupportedOperationSignal := ErrorSignal newSignalMayProceed:true.
- UnsupportedOperationSignal nameClass:self message:#unsupportedOperationSignal.
- UnsupportedOperationSignal notifierString:'operation not supported by this OS'.
+ ErrorSignal := Object errorSignal newSignalMayProceed:true.
+ ErrorSignal nameClass:self message:#errorSignal.
+ ErrorSignal notifierString:'OS error encountered'.
+
+ AccessDeniedErrorSignal := ErrorSignal newSignalMayProceed:true.
+ AccessDeniedErrorSignal nameClass:self message:#accessDeniedError.
+ AccessDeniedErrorSignal notifierString:'OS access denied'.
+
+ FileNotFoundErrorSignal := ErrorSignal newSignalMayProceed:true.
+ FileNotFoundErrorSignal nameClass:self message:#fileNotFoundErrorSignal.
+ FileNotFoundErrorSignal notifierString:'OS file not found'.
+
+ InvalidArgumentsSignal := ErrorSignal newSignalMayProceed:true.
+ InvalidArgumentsSignal nameClass:self message:#invalidArgumentsSignal.
+ InvalidArgumentsSignal notifierString:'bad arg to OS call'.
+
+ UnsupportedOperationSignal := ErrorSignal newSignalMayProceed:true.
+ UnsupportedOperationSignal nameClass:self message:#unsupportedOperationSignal.
+ UnsupportedOperationSignal notifierString:'operation not supported by this OS'.
]
"Modified: / 19.5.1999 / 14:21:28 / cg"
@@ -185,21 +185,21 @@
osType := self getSystemType.
osType = 'win32' ifTrue:[
- cls := Win32OperatingSystem
+ cls := Win32OperatingSystem
] ifFalse:[
- osType = 'os2' ifTrue:[
- cls := OS2OperatingSystem
- ] ifFalse:[
- osType = 'macos' ifTrue:[
- cls := MacOperatingSystem
- ] ifFalse:[
- ((osType = 'VMS') or:[osType = 'openVMS']) ifTrue:[
- cls := OpenVMSOperatingSystem
- ] ifFalse:[
- cls := UnixOperatingSystem
- ]
- ]
- ]
+ osType = 'os2' ifTrue:[
+ cls := OS2OperatingSystem
+ ] ifFalse:[
+ osType = 'macos' ifTrue:[
+ cls := MacOperatingSystem
+ ] ifFalse:[
+ ((osType = 'VMS') or:[osType = 'openVMS']) ifTrue:[
+ cls := OpenVMSOperatingSystem
+ ] ifFalse:[
+ cls := UnixOperatingSystem
+ ]
+ ]
+ ]
].
OperatingSystem := ConcreteClass := cls.
! !
@@ -553,7 +553,7 @@
"return the last errors number.
See also: #lastErrorSymbol and #lastErrorString.
Notice: having a single error number is a bad idea in a multithreaded
- environment - this interface will change."
+ environment - this interface will change."
LastErrorNumber := nil.
@@ -595,8 +595,8 @@
and should be replaced by a resource lookup before being presented to the user."
^ Array
- with:#'ERROR_OTHER'
- with:('ErrorNr: ' , errNr printString)
+ with:#'ERROR_OTHER'
+ with:('ErrorNr: ' , errNr printString)
"
OperatingSystem errorSymbolAndTextForNumber:4
@@ -635,7 +635,7 @@
"return the last errors number.
See also: #lastErrorSymbol and #lastErrorString.
Notice: having a single error number is a bad idea in a multithreaded
- environment - this interface will change."
+ environment - this interface will change."
^ LastErrorNumber
@@ -648,7 +648,7 @@
"return a message string describing the last error.
See also: #lastErrorNumber and #lastErrorSymbol.
Notice: having a single error number is a bad idea in a multithreaded
- environment - this interface will change."
+ environment - this interface will change."
LastErrorNumber isNil ifTrue:[^ nil].
^ self errorTextForNumber:LastErrorNumber
@@ -662,7 +662,7 @@
"return a symbol (such as #EBADF or #EACCESS) describing the last error.
See also: #lastErrorNumber and #lastErrorString.
Notice: having a single error number is a bad idea in a multithreaded
- environment - this interface will change."
+ environment - this interface will change."
LastErrorNumber isNil ifTrue:[^ nil].
^ self errorSymbolForNumber:LastErrorNumber
@@ -706,14 +706,14 @@
Can be used on UNIX with fork or on other systems to chain to another program."
^ self
- exec:aCommandPath
- withArguments:argArray
- environment:nil
- fileDescriptors:nil
- closeDescriptors:nil
- fork:false
- newPgrp:false
- inDirectory:nil
+ exec:aCommandPath
+ withArguments:argArray
+ environment:nil
+ fileDescriptors:nil
+ closeDescriptors:nil
+ fork:false
+ newPgrp:false
+ inDirectory:nil
"/ never reached ...
@@ -724,31 +724,31 @@
"Internal lowLevel entry for combined fork & exec;
If fork is false (chain a command):
- execute the OS command specified by the argument, aCommandPath, with
- arguments in argArray (no arguments, if nil).
- If successful, this method does not return and smalltalk is gone.
- If not successful, it does return.
- Normal use is with forkForCommand.
+ execute the OS command specified by the argument, aCommandPath, with
+ arguments in argArray (no arguments, if nil).
+ If successful, this method does not return and smalltalk is gone.
+ If not successful, it does return.
+ Normal use is with forkForCommand.
If fork is true (subprocess command execution):
- fork a child to do the above.
- The process id of the child process is returned; nil if the fork failed.
+ fork a child to do the above.
+ The process id of the child process is returned; nil if the fork failed.
fdArray contains the filedescriptors, to be used for the child (if fork is true).
- fdArray[1] = 15 -> use fd 15 as stdin.
- If an element of the array is set to nil, the corresponding filedescriptor
- will be closed for the child.
- fdArray[0] == StdIn for child
- fdArray[1] == StdOut for child
- fdArray[2] == StdErr for child
- on VMS, these must be channels as returned by createMailBox.
+ fdArray[1] = 15 -> use fd 15 as stdin.
+ If an element of the array is set to nil, the corresponding filedescriptor
+ will be closed for the child.
+ fdArray[0] == StdIn for child
+ fdArray[1] == StdOut for child
+ fdArray[2] == StdErr for child
+ on VMS, these must be channels as returned by createMailBox.
closeFdArray contains descriptors that will be closed in the subprocess.
- closeDescriptors are ignored in the WIN32 & VMS versions.
+ closeDescriptors are ignored in the WIN32 & VMS versions.
If newPgrp is true, the subprocess will be established in a new process group.
- The processgroup will be equal to id.
- newPgrp is not used on WIN32 and VMS systems.
+ The processgroup will be equal to id.
+ newPgrp is not used on WIN32 and VMS systems.
env specifies environment variables which are passed differently from
the current environment. If non-nil, it must be a dictionary providing
@@ -756,28 +756,28 @@
To pass a variable as empty (i.e. unset), pass a nil value.
Notice: this used to be two separate ST-methods; however, in order to use
- vfork on some machines, it had to be merged into one, to avoid write
- accesses to ST/X memory from the vforked-child.
- The code below only does read accesses."
+ vfork on some machines, it had to be merged into one, to avoid write
+ accesses to ST/X memory from the vforked-child.
+ The code below only does read accesses."
^ self
- exec:aCommandPath
- withArguments:argColl
- environment:env
- fileDescriptors:fdColl
- closeDescriptors:closeFdColl
- fork:doFork
- newPgrp:newPgrp
- inDirectory:nil
+ exec:aCommandPath
+ withArguments:argColl
+ environment:env
+ fileDescriptors:fdColl
+ closeDescriptors:closeFdColl
+ fork:doFork
+ newPgrp:newPgrp
+ inDirectory:nil
"
|id|
id := OperatingSystem fork.
id == 0 ifTrue:[
- 'I am the child'.
- OperatingSystem exec:'/bin/ls' withArguments:#('ls' '/tmp').
- 'not reached'.
+ 'I am the child'.
+ OperatingSystem exec:'/bin/ls' withArguments:#('ls' '/tmp').
+ 'not reached'.
]
"
"
@@ -785,11 +785,11 @@
id := OperatingSystem fork.
id == 0 ifTrue:[
- 'I am the child'.
- OperatingSystem
- exec:'/bin/sh'
- withArguments:#('sh' '-c' 'sleep 2;echo 1;sleep 2;echo 2').
- 'not reached'.
+ 'I am the child'.
+ OperatingSystem
+ exec:'/bin/sh'
+ withArguments:#('sh' '-c' 'sleep 2;echo 1;sleep 2;echo 2').
+ 'not reached'.
].
id printNL.
(Delay forSeconds:3.5) wait.
@@ -813,57 +813,57 @@
exec:aCommandPath withArguments:argArray fileDescriptors:fdArray closeDescriptors:closeFdArray fork:doFork newPgrp:newPgrp
"combined fork & exec;
If fork is false (chain a command):
- execute the OS command specified by the argument, aCommandPath, with
- arguments in argArray (no arguments, if nil).
- If successful, this method does not return and smalltalk is gone.
- If not successful, it does return.
- Normal use is with forkForCommand.
+ execute the OS command specified by the argument, aCommandPath, with
+ arguments in argArray (no arguments, if nil).
+ If successful, this method does not return and smalltalk is gone.
+ If not successful, it does return.
+ Normal use is with forkForCommand.
If fork is true (subprocess command execution):
- fork a child to do the above.
- The process id of the child process is returned; nil if the fork failed.
+ fork a child to do the above.
+ The process id of the child process is returned; nil if the fork failed.
fdArray contains the filedescriptors, to be used for the child (if fork is true).
- fdArray[1] = 15 -> use fd 15 as stdin.
- If an element of the array is set to nil, the corresponding filedescriptor
- will be closed for the child.
- fdArray[0] == StdIn for child
- fdArray[1] == StdOut for child
- fdArray[2] == StdErr for child
- on VMS, these must be channels as returned by createMailBox.
+ fdArray[1] = 15 -> use fd 15 as stdin.
+ If an element of the array is set to nil, the corresponding filedescriptor
+ will be closed for the child.
+ fdArray[0] == StdIn for child
+ fdArray[1] == StdOut for child
+ fdArray[2] == StdErr for child
+ on VMS, these must be channels as returned by createMailBox.
closeFdArray contains descriptors that will be closed in the subprocess.
- closeDescriptors are ignored in the WIN32 & VMS versions.
+ closeDescriptors are ignored in the WIN32 & VMS versions.
NOTE that in WIN32 the fds are HANDLES!!
If newPgrp is true, the subprocess will be established in a new process group.
- The processgroup will be equal to id.
- newPgrp is not used on WIN32 and VMS systems.
+ The processgroup will be equal to id.
+ newPgrp is not used on WIN32 and VMS systems.
Notice: this used to be two separate ST-methods; however, in order to use
- vfork on some machines, it had to be merged into one, to avoid write
- accesses to ST/X memory from the vforked-child.
- The code below only does read accesses."
+ vfork on some machines, it had to be merged into one, to avoid write
+ accesses to ST/X memory from the vforked-child.
+ The code below only does read accesses."
^ self
- exec:aCommandPath
- withArguments:argArray
- environment:nil
- fileDescriptors:fdArray
- closeDescriptors:closeFdArray
- fork:doFork
- newPgrp:newPgrp
- inDirectory:nil
+ exec:aCommandPath
+ withArguments:argArray
+ environment:nil
+ fileDescriptors:fdArray
+ closeDescriptors:closeFdArray
+ fork:doFork
+ newPgrp:newPgrp
+ inDirectory:nil
"
|id|
id := OperatingSystem fork.
id == 0 ifTrue:[
- 'I am the child'.
- OperatingSystem exec:'/bin/ls' withArguments:#('ls' '/tmp').
- 'not reached'.
+ 'I am the child'.
+ OperatingSystem exec:'/bin/ls' withArguments:#('ls' '/tmp').
+ 'not reached'.
]
"
"
@@ -871,11 +871,11 @@
id := OperatingSystem fork.
id == 0 ifTrue:[
- 'I am the child'.
- OperatingSystem
- exec:'/bin/sh'
- withArguments:#('sh' '-c' 'sleep 2;echo 1;sleep 2;echo 2').
- 'not reached'.
+ 'I am the child'.
+ OperatingSystem
+ exec:'/bin/sh'
+ withArguments:#('sh' '-c' 'sleep 2;echo 1;sleep 2;echo 2').
+ 'not reached'.
].
id printNL.
(Delay forSeconds:3.5) wait.
@@ -893,14 +893,14 @@
Not needed with Unix"
^ self
- exec:aCommandPath
- withArguments:argArray
- environment:nil
- fileDescriptors:fdArray
- closeDescriptors:closeFdArray
- fork:doFork
- newPgrp:newPgrp
- inDirectory:aDirectory
+ exec:aCommandPath
+ withArguments:argArray
+ environment:nil
+ fileDescriptors:fdArray
+ closeDescriptors:closeFdArray
+ fork:doFork
+ newPgrp:newPgrp
+ inDirectory:aDirectory
"Modified: / 12.11.1998 / 14:47:58 / cg"
"Created: / 12.11.1998 / 14:49:18 / cg"
@@ -913,26 +913,26 @@
(typically, the xterm window)"
^ self
- exec:aCommandPath
- withArguments:argArray
- environment:nil
- fileDescriptors:nil
- closeDescriptors:nil
- fork:doFork
- newPgrp:false
- inDirectory:nil
+ exec:aCommandPath
+ withArguments:argArray
+ environment:nil
+ fileDescriptors:nil
+ closeDescriptors:nil
+ fork:doFork
+ newPgrp:false
+ inDirectory:nil
"
|id|
id := OperatingSystem fork.
id == 0 ifTrue:[
- 'I am the child'.
- OperatingSystem
- exec:'/bin/ls'
- withArguments:#('ls' '/tmp')
- fork:false.
- 'not reached'.
+ 'I am the child'.
+ OperatingSystem
+ exec:'/bin/ls'
+ withArguments:#('ls' '/tmp')
+ fork:false.
+ 'not reached'.
]
"
@@ -941,12 +941,12 @@
id := OperatingSystem fork.
id == 0 ifTrue:[
- 'I am the child'.
- OperatingSystem
- exec:'/bin/sh'
- withArguments:#('sh' '-c' 'sleep 2;echo 1;sleep 2;echo 2')
- fork:false.
- 'not reached'.
+ 'I am the child'.
+ OperatingSystem
+ exec:'/bin/sh'
+ withArguments:#('sh' '-c' 'sleep 2;echo 1;sleep 2;echo 2')
+ fork:false.
+ 'not reached'.
].
id printNL.
(Delay forSeconds:3.5) wait.
@@ -966,26 +966,26 @@
(typically, the xterm window)"
^ self
- exec:aCommandPath
- withArguments:argArray
- environment:nil
- fileDescriptors:nil
- closeDescriptors:nil
- fork:doFork
- newPgrp:false
- inDirectory:aDirectory
+ exec:aCommandPath
+ withArguments:argArray
+ environment:nil
+ fileDescriptors:nil
+ closeDescriptors:nil
+ fork:doFork
+ newPgrp:false
+ inDirectory:aDirectory
"
|id|
id := OperatingSystem fork.
id == 0 ifTrue:[
- 'I am the child'.
- OperatingSystem
- exec:'/bin/ls'
- withArguments:#('ls' '/tmp')
- fork:false.
- 'not reached'.
+ 'I am the child'.
+ OperatingSystem
+ exec:'/bin/ls'
+ withArguments:#('ls' '/tmp')
+ fork:false.
+ 'not reached'.
]
"
@@ -994,12 +994,12 @@
id := OperatingSystem fork.
id == 0 ifTrue:[
- 'I am the child'.
- OperatingSystem
- exec:'/bin/sh'
- withArguments:#('sh' '-c' 'sleep 2;echo 1;sleep 2;echo 2')
- fork:false.
- 'not reached'.
+ 'I am the child'.
+ OperatingSystem
+ exec:'/bin/sh'
+ withArguments:#('sh' '-c' 'sleep 2;echo 1;sleep 2;echo 2')
+ fork:false.
+ 'not reached'.
].
id printNL.
(Delay forSeconds:3.5) wait.
@@ -1029,12 +1029,12 @@
Return true if successful, false otherwise."
^ self
- executeCommand:aCommandString
- inputFrom:nil
- outputTo:nil
- errorTo:nil
- inDirectory:nil
- onError:[:status| false]
+ executeCommand:aCommandString
+ inputFrom:nil
+ outputTo:nil
+ errorTo:nil
+ inDirectory:nil
+ onError:[:status| false]
"unix:
@@ -1310,27 +1310,27 @@
(containing the exit status) as argument."
^ self
- executeCommand:aCommandString
- inputFrom:anExternalInStream
- outputTo:anExternalOutStream
- errorTo:anExternalErrStream
- inDirectory:nil
- onError:aBlock
+ executeCommand:aCommandString
+ inputFrom:anExternalInStream
+ outputTo:anExternalOutStream
+ errorTo:anExternalErrStream
+ inDirectory:nil
+ onError:aBlock
"
- OperatingSystem
- executeCommand:'dir'
- inputFrom:nil
- outputTo:nil
- errorTo:nil
- onError:[:status | Transcript flash]
+ OperatingSystem
+ executeCommand:'dir'
+ inputFrom:nil
+ outputTo:nil
+ errorTo:nil
+ onError:[:status | Transcript flash]
- OperatingSystem
- executeCommand:'foo'
- inputFrom:nil
- outputTo:nil
- errorTo:nil
- onError:[:status | Transcript flash]
+ OperatingSystem
+ executeCommand:'foo'
+ inputFrom:nil
+ outputTo:nil
+ errorTo:nil
+ onError:[:status | Transcript flash]
"
"Modified: / 10.11.1998 / 20:51:39 / cg"
@@ -1345,12 +1345,12 @@
(containing the exit status) as argument."
^ self
- executeCommand:aCommandString
- inputFrom:nil
- outputTo:nil
- errorTo:nil
- inDirectory:nil
- onError:aBlock
+ executeCommand:aCommandString
+ inputFrom:nil
+ outputTo:nil
+ errorTo:nil
+ inDirectory:nil
+ onError:aBlock
"unix:
@@ -1445,26 +1445,26 @@
|result|
PipeFailed ~~ true ifTrue:[
- PipeStream openErrorSignal handle:[:ex |
- PipeFailed := true.
- 'OperatingSystem [warning]: cannot fork/popen' errorPrintCR.
- ex return.
- ] do:[
- |p|
-
- p := PipeStream
- readingFrom:aCommand
- errorDisposition:#discard
- inDirectory:nil.
- p notNil ifTrue:[
- p atEnd ifTrue:[
- result := ''
- ] ifFalse:[
- result := p nextLine.
- ].
- p close
- ].
- ].
+ PipeStream openErrorSignal handle:[:ex |
+ PipeFailed := true.
+ 'OperatingSystem [warning]: cannot fork/popen' errorPrintCR.
+ ex return.
+ ] do:[
+ |p|
+
+ p := PipeStream
+ readingFrom:aCommand
+ errorDisposition:#discard
+ inDirectory:nil.
+ p notNil ifTrue:[
+ p atEnd ifTrue:[
+ result := ''
+ ] ifFalse:[
+ result := p nextLine.
+ ].
+ p close
+ ].
+ ].
].
^ result
@@ -1536,11 +1536,11 @@
or #killProcess: to stop it."
^ self
- startProcess:aCommandString
- inputFrom:nil
- outputTo:nil
- errorTo:nil
- inDirectory:nil
+ startProcess:aCommandString
+ inputFrom:nil
+ outputTo:nil
+ errorTo:nil
+ inDirectory:nil
"
|pid|
@@ -1560,11 +1560,11 @@
|pid|
pid := OperatingSystem
- startProcess:'dir/l'
- inputFrom:nil
- outputTo:Stdout
- errorTo:nil
- inDirectory:nil.
+ startProcess:'dir/l'
+ inputFrom:nil
+ outputTo:Stdout
+ errorTo:nil
+ inDirectory:nil.
(Delay forSeconds:2) wait.
OperatingSystem killProcess:pid.
"
@@ -1583,11 +1583,11 @@
or #killProcess: to stop it."
^ self
- startProcess:aCommandString
- inputFrom:nil
- outputTo:nil
- errorTo:nil
- inDirectory:aDirectory
+ startProcess:aCommandString
+ inputFrom:nil
+ outputTo:nil
+ errorTo:nil
+ inDirectory:aDirectory
"
|pid|
@@ -1613,11 +1613,11 @@
or #killProcess: to stop it."
^ self
- startProcess:aCommandString
- inputFrom:anExternalInStream
- outputTo:anExternalOutStream
- errorTo:anExternalErrStream
- inDirectory:nil
+ startProcess:aCommandString
+ inputFrom:anExternalInStream
+ outputTo:anExternalOutStream
+ errorTo:anExternalErrStream
+ inDirectory:nil
"Modified: / 10.11.1998 / 20:59:05 / cg"
!
@@ -1706,10 +1706,10 @@
Here, false is returned and the caller should be prepared
for a fallBack solution.
Notice:
- this is not a public interface; instead, it is used
- internally by the Filename class, to try a fast copy
- before doing things manually.
- Please use Filename recursiveCopyTo:"
+ this is not a public interface; instead, it is used
+ internally by the Filename class, to try a fast copy
+ before doing things manually.
+ Please use Filename recursiveCopyTo:"
^ false
@@ -1729,8 +1729,8 @@
self createDirectory:dirName.
(self isDirectory:dirName) ifFalse:[
- (self recursiveCreateDirectory:(dirName asFilename directoryName)) ifFalse:[^ false].
- ^ self createDirectory:dirName
+ (self recursiveCreateDirectory:(dirName asFilename directoryName)) ifFalse:[^ false].
+ ^ self createDirectory:dirName
].
^ true
@@ -1748,10 +1748,10 @@
Here, false is returned and the caller should be prepared
for a fallBack solution.
Notice:
- this is not a public interface; instead, it is used
- internally by the Filename class, to try a fast remove
- before doing things manually.
- Please use Filename recursiveRemoveDirectory:"
+ this is not a public interface; instead, it is used
+ internally by the Filename class, to try a fast remove
+ before doing things manually.
+ Please use Filename recursiveRemoveDirectory:"
^ false
@@ -1819,7 +1819,7 @@
"
this could have been implemented as:
- (self infoOf:aPathName) at:#mode
+ (self infoOf:aPathName) at:#mode
but for huge directory searches the code below is faster
"
@@ -1997,13 +1997,31 @@
"/ root, home and current directories.
"/
^ Array
- with:'/'
- with:(self getHomeDirectory)
- with:(Filename currentDirectory pathName)
+ with:'/'
+ with:(self getHomeDirectory)
+ with:(Filename currentDirectory pathName)
"Modified: / 5.5.1999 / 01:06:26 / cg"
!
+getMountedVolumes
+ "return info about mounted volumes.
+ The amount of information returned depends upon the OS, and is
+ not guaranteed to be consistent across architectures.
+ On unix, the information returned is (at least):
+ mountPoint - mount point
+ fileSystem - device or NFS-remotePath
+ "
+
+ ^ #()
+
+ "
+ OperatingSystem getMountedVolumes
+ "
+
+ "Modified: / 22.5.1999 / 00:36:06 / cg"
+!
+
getNullDevice
"get the name of the null-device. Nil is returned if not supported"
@@ -2039,16 +2057,16 @@
"return some object filled with info for the file 'aPathName';
the info (for which corresponding access methods are understood by
the returned object) is:
- type - a symbol giving the files type
- mode - numeric access mode
- uid - owners user id
- gid - owners group id
- size - files size
- id - files number (i.e. inode number)
- accessed - last access time (as Timestamp)
- modified - last modification time (as Timestamp)
- statusChanged - last status change time (as Timestamp)
- alternativeName - (windows only: the MSDOS name of the file)
+ type - a symbol giving the files type
+ mode - numeric access mode
+ uid - owners user id
+ gid - owners group id
+ size - files size
+ id - files number (i.e. inode number)
+ accessed - last access time (as Timestamp)
+ modified - last modification time (as Timestamp)
+ statusChanged - last status change time (as Timestamp)
+ alternativeName - (windows only: the MSDOS name of the file)
Some of the fields may be returned as nil on systems which do not provide
all of the information.
@@ -2308,8 +2326,8 @@
disableTimer
"disable timer interrupts.
WARNING:
- the system will not operate correctly with timer interrupts
- disabled, because no scheduling or timeouts are possible."
+ the system will not operate correctly with timer interrupts
+ disabled, because no scheduling or timeouts are possible."
self subclassResponsibility
!
@@ -2318,9 +2336,9 @@
"disable userInterrupt processing;
when disabled, no ^C processing takes place.
WARNING:
- If at all, use this only for debugged stand-alone applications, since
- no exit to the debugger is possible with user interrupts disabled.
- We recommend setting up a handler for the signal instead of disabling it."
+ If at all, use this only for debugged stand-alone applications, since
+ no exit to the debugger is possible with user interrupts disabled.
+ We recommend setting up a handler for the signal instead of disabling it."
self disableSignal:(self sigBREAK).
self disableSignal:(self sigINT).
@@ -2443,8 +2461,8 @@
The process has a no chance to do some cleanup.
WARNING: in order to avoid zombie processes (on unix),
- you may have to fetch the processes exitstatus with
- OperatingSystem>>getStatusOfProcess:aProcessId."
+ you may have to fetch the processes exitstatus with
+ OperatingSystem>>getStatusOfProcess:aProcessId."
self subclassResponsibility
@@ -2456,8 +2474,8 @@
The process has NO chance to do some cleanup.
WARNING: in order to avoid zombie processes (on unix),
- you may have to fetch the processes exitstatus with
- OperatingSystem>>getStatusOfProcess:aProcessId."
+ you may have to fetch the processes exitstatus with
+ OperatingSystem>>getStatusOfProcess:aProcessId."
self subclassResponsibility
@@ -2507,7 +2525,7 @@
aSignalNumber == self sigDANGER ifTrue:[^ 'low on paging space'].
"notice: many systems map SIGPOLL and/or SIGUSR onto SIGIO
- therefore, keep SIGIO always above the two below"
+ therefore, keep SIGIO always above the two below"
aSignalNumber == self sigPOLL ifTrue:[^ 'io available'].
aSignalNumber == self sigURG ifTrue:[^ 'urgent'].
@@ -2524,7 +2542,7 @@
operatingSystem-signal occurs, or nil"
OSSignals notNil ifTrue:[
- ^ OSSignals at:signalNumber ifAbsent:[nil]
+ ^ OSSignals at:signalNumber ifAbsent:[nil]
].
^ nil
!
@@ -2533,7 +2551,7 @@
"install a signal to be raised when an operatingSystem-signal occurs"
OSSignals isNil ifTrue:[
- OSSignals := Array new:32
+ OSSignals := Array new:32
].
OSSignals at:signalNumber put:aSignal
!
@@ -2545,9 +2563,9 @@
Do not confuse UNIX signals with Smalltalk-Signals.
WARNING: in order to avoid zombie processes (on unix),
- you may have to fetch the processes exitstatus with
- OperatingSystem>>getStatusOfProcess:aProcessId
- if the signal terminates that process."
+ you may have to fetch the processes exitstatus with
+ OperatingSystem>>getStatusOfProcess:aProcessId
+ if the signal terminates that process."
self subclassResponsibility
!
@@ -2559,7 +2577,7 @@
On systems, where no virtual timer is available, use the real timer
(which is of course less correct).
OBSOLETE: the new messageTally runs as a high prio process, not using
- spy interrupts."
+ spy interrupts."
^ false
!
@@ -2567,7 +2585,7 @@
stopSpyTimer
"stop spy timing - disable spy timer.
OBSOLETE: the new messageTally runs as a high prio process, not using
- spy interrupts."
+ spy interrupts."
^ false
!
@@ -2577,8 +2595,8 @@
The process has a chance to do some cleanup.
WARNING: in order to avoid zombie processes (on unix),
- you may have to fetch the processes exitstatus with
- OperatingSystem>>getStatusOfProcess:aProcessId."
+ you may have to fetch the processes exitstatus with
+ OperatingSystem>>getStatusOfProcess:aProcessId."
self subclassResponsibility
!
@@ -2588,8 +2606,8 @@
The process has a chance to do some cleanup.
WARNING: in order to avoid zombie processes (on unix),
- you may have to fetch the processes exitstatus with
- OperatingSystem>>getStatusOfProcess:aProcessId."
+ you may have to fetch the processes exitstatus with
+ OperatingSystem>>getStatusOfProcess:aProcessId."
self subclassResponsibility
!
@@ -2632,7 +2650,7 @@
int code = 1;
if (__isSmallInteger(exitCode)) {
- code = __intVal(exitCode);
+ code = __intVal(exitCode);
}
__mainExit(code);
%}
@@ -2786,7 +2804,7 @@
getDomainName
"return the domain this host is in.
Notice:
- not all systems support this; on some, 'unknown' is returned."
+ not all systems support this; on some, 'unknown' is returned."
self subclassResponsibility
!
@@ -2801,7 +2819,7 @@
"return the hostname we are running on - if there is
a HOST environment variable, we are much faster here ...
Notice:
- not all systems support this; on some, 'unknown' is returned."
+ not all systems support this; on some, 'unknown' is returned."
self subclassResponsibility
!
@@ -2810,42 +2828,42 @@
"return a dictionary filled with values from the locale information;
Not all fields may be present, depending on the OS's setup and capabilities.
Possible fields are:
- decimalPoint <String>
-
- thousandsSep <String>
-
- internationalCurrencySymbol <String>
-
- currencySymbol <String>
-
- monetaryDecimalPoint <String>
-
- monetaryThousandsSeparator <String>
-
- positiveSign <String>
-
- negativeSign <String>
-
- internationalFractionalDigits <Integer>
-
- fractionalDigits <Integer>
-
- positiveSignPrecedesCurrencySymbol <Boolean>
-
- negativeSignPrecedesCurrencySymbol <Boolean>
-
- positiveSignSeparatedBySpaceFromCurrencySymbol <Boolean>
-
- negativeSignSeparatedBySpaceFromCurrencySymbol <Boolean>
-
- positiveSignPosition <Symbol>
- one of: #parenthesesAround,
- #signPrecedes,
- #signSuceeds,
- #signPrecedesCurrencySymbol,
- #signSuceedsCurrencySymbol
-
- negativeSignPosition <like above>
+ decimalPoint <String>
+
+ thousandsSep <String>
+
+ internationalCurrencySymbol <String>
+
+ currencySymbol <String>
+
+ monetaryDecimalPoint <String>
+
+ monetaryThousandsSeparator <String>
+
+ positiveSign <String>
+
+ negativeSign <String>
+
+ internationalFractionalDigits <Integer>
+
+ fractionalDigits <Integer>
+
+ positiveSignPrecedesCurrencySymbol <Boolean>
+
+ negativeSignPrecedesCurrencySymbol <Boolean>
+
+ positiveSignSeparatedBySpaceFromCurrencySymbol <Boolean>
+
+ negativeSignSeparatedBySpaceFromCurrencySymbol <Boolean>
+
+ positiveSignPosition <Symbol>
+ one of: #parenthesesAround,
+ #signPrecedes,
+ #signSuceeds,
+ #signPrecedesCurrencySymbol,
+ #signSuceedsCurrencySymbol
+
+ negativeSignPosition <like above>
it is up to the application to deal with undefined values.
@@ -3029,7 +3047,7 @@
"if supported by the OS, return the systemID;
a unique per machine identification.
WARNING:
- not all systems support this; on some, 'unknown' is returned."
+ not all systems support this; on some, 'unknown' is returned."
^ 'unknown'
@@ -3051,16 +3069,16 @@
This method is mainly provided to augment error reports with some system
information.
(in case of system/version specific OS errors, conditional workarounds and patches
- may be based upon this info).
+ may be based upon this info).
Your application should NOT depend upon this in any way.
The returned info may (or may not) contain:
- #system -> some operating system identification (irix, Linux, nt, win32s ...)
- #version -> OS version (some os version identification)
- #release -> OS release (3.5, 1.2.1 ...)
- #node -> some host identification (hostname)
- #domain -> domain name (hosts domain)
- #machine -> type of machine (i586, mips ...)
+ #system -> some operating system identification (irix, Linux, nt, win32s ...)
+ #version -> OS version (some os version identification)
+ #release -> OS release (3.5, 1.2.1 ...)
+ #node -> some host identification (hostname)
+ #domain -> domain name (hosts domain)
+ #machine -> type of machine (i586, mips ...)
"
|info|
@@ -3187,11 +3205,11 @@
maxFileNameLength
"return the max number of characters in a filename.
CAVEAT:
- Actually, the following is somewhat wrong - some systems
- support different sizes, depending on the volume.
- We return a somewhat conservative number here.
- Another entry, to query for volume specific max
- will be added in the future."
+ Actually, the following is somewhat wrong - some systems
+ support different sizes, depending on the volume.
+ We return a somewhat conservative number here.
+ Another entry, to query for volume specific max
+ will be added in the future."
self subclassResponsibility
!
@@ -3362,20 +3380,20 @@
"/
homePath := OperatingSystem getHomeDirectory.
homePath notNil ifTrue:[
- sysPath add:homePath.
-
- "/
- "/ a users private smalltalk directory in its home (login) directory
- "/
- OperatingSystem isUNIXlike ifTrue:[
- priv := '.smalltalk'.
- ] ifFalse:[
- priv := 'smalltalk'.
- ].
- userPrivateSTXDir := homePath asFilename constructString:priv.
- (userPrivateSTXDir asFilename isDirectory) ifTrue:[
- sysPath add:userPrivateSTXDir
- ].
+ sysPath add:homePath.
+
+ "/
+ "/ a users private smalltalk directory in its home (login) directory
+ "/
+ OperatingSystem isUNIXlike ifTrue:[
+ priv := '.smalltalk'.
+ ] ifFalse:[
+ priv := 'smalltalk'.
+ ].
+ userPrivateSTXDir := homePath asFilename constructString:priv.
+ (userPrivateSTXDir asFilename isDirectory) ifTrue:[
+ sysPath add:userPrivateSTXDir
+ ].
].
"/
@@ -3383,11 +3401,11 @@
"/
p := OperatingSystem getEnvironment:'SMALLTALK_LIBDIR'.
p notNil ifTrue:[
- sysPath add:p
+ sysPath add:p
].
p := OperatingSystem getEnvironment:'STX_LIBDIR'.
p notNil ifTrue:[
- sysPath add:p
+ sysPath add:p
].
^ sysPath
! !
@@ -3516,8 +3534,8 @@
Use the millisecondTimeXXX:-methods to compare and add time deltas - these know about the wrap.
BAD DESIGN:
- This should be changed to return some instance of RelativeTime,
- and these computations moved there.
+ This should be changed to return some instance of RelativeTime,
+ and these computations moved there.
Dont use this method in application code since it is an internal (private)
interface. For compatibility with ST-80, use Time millisecondClockValue.
@@ -3566,9 +3584,9 @@
then := self millisecondTimeAdd:now and:millis.
[self millisecondTime:then isAfter:now] whileTrue:[
- delta := self millisecondTimeDeltaBetween:then and:now.
- self selectOnAnyReadable:nil writable:nil exception:nil withTimeOut:delta.
- now := self getMillisecondTime.
+ delta := self millisecondTimeDeltaBetween:then and:now.
+ self selectOnAnyReadable:nil writable:nil exception:nil withTimeOut:delta.
+ now := self getMillisecondTime.
]
"
@@ -3584,13 +3602,13 @@
This should really be moved to some RelativeTime class."
(msTime1 > msTime2) ifTrue:[
- ((msTime1 - msTime2) >= 16r10000000) ifTrue:[
- ^ false
- ].
- ^ true
+ ((msTime1 - msTime2) >= 16r10000000) ifTrue:[
+ ^ false
+ ].
+ ^ true
].
((msTime2 - msTime1) > 16r10000000) ifTrue:[
- ^ true
+ ^ true
].
^ false
!
@@ -3620,7 +3638,7 @@
better yet: create a subclass of Integer named LimitedRangeInteger."
(msTime1 > msTime2) ifTrue:[
- ^ msTime1 - msTime2
+ ^ msTime1 - msTime2
].
^ msTime1 + 16r10000000 - msTime2
@@ -3800,7 +3818,7 @@
"/ fallBack dummy
aNumber == self getUserID ifTrue:[
- ^ self getLoginName
+ ^ self getLoginName
].
^ '? (' , aNumber printString , ')'
@@ -3879,20 +3897,20 @@
This depends on a working select or FIONREAD to be provided by the OS."
self supportsSelect ifFalse:[
- "/ mhmh - what should we do then ?
- "/ For now, return true as if data was present,
- "/ and let the thread fall into the read.
- "/ It will then (hopefully) be desceduled there and
- "/ effectively polling for input.
-
- ^ true
+ "/ mhmh - what should we do then ?
+ "/ For now, return true as if data was present,
+ "/ and let the thread fall into the read.
+ "/ It will then (hopefully) be desceduled there and
+ "/ effectively polling for input.
+
+ ^ true
].
(self selectOnAnyReadable:(Array with:fd)
- writable:nil
- exception:nil
- withTimeOut:0) == fd
- ifTrue:[^ true].
+ writable:nil
+ exception:nil
+ withTimeOut:0) == fd
+ ifTrue:[^ true].
^ false
!
@@ -3902,19 +3920,19 @@
be finished."
self supportsSelect ifFalse:[
- "/ mhmh - what should we do then ?
- "/ For now, return true as if data was present,
- "/ and let the thread fall into the write.
- "/ It will then (hopefully) be desceduled there and
- "/ effectively polling for output.
- ^ true
+ "/ mhmh - what should we do then ?
+ "/ For now, return true as if data was present,
+ "/ and let the thread fall into the write.
+ "/ It will then (hopefully) be desceduled there and
+ "/ effectively polling for output.
+ ^ true
].
(self selectOnAnyReadable:(Array with:fd)
- writable:(Array with:fd)
- exception:nil
- withTimeOut:0) == fd
- ifTrue:[^ true].
+ writable:(Array with:fd)
+ exception:nil
+ withTimeOut:0) == fd
+ ifTrue:[^ true].
^ false
!
@@ -3923,12 +3941,12 @@
A zero timeout-time will immediately return (i.e. poll).
Return fd if i/o ok, nil if timed-out or interrupted.
Obsolete:
- This is a leftover method and will vanish."
+ This is a leftover method and will vanish."
^ self selectOnAnyReadable:(Array with:fd1 with:fd2)
- writable:(Array with:fd1 with:fd2)
- exception:nil
- withTimeOut:millis
+ writable:(Array with:fd1 with:fd2)
+ exception:nil
+ withTimeOut:millis
!
selectOn:fd withTimeOut:millis
@@ -3939,9 +3957,9 @@
Experimental."
^ self selectOnAnyReadable:(Array with:fd)
- writable:(Array with:fd)
- exception:nil
- withTimeOut:millis
+ writable:(Array with:fd)
+ exception:nil
+ withTimeOut:millis
!
selectOnAny:fdArray withTimeOut:millis
@@ -3951,9 +3969,9 @@
Experimental."
^ self selectOnAnyReadable:fdArray
- writable:fdArray
- exception:nil
- withTimeOut:millis
+ writable:fdArray
+ exception:nil
+ withTimeOut:millis
!
selectOnAnyReadable:fdArray withTimeOut:millis
@@ -3964,9 +3982,9 @@
Experimental."
^ self selectOnAnyReadable:fdArray
- writable:nil
- exception:nil
- withTimeOut:millis
+ writable:nil
+ exception:nil
+ withTimeOut:millis
!
selectOnAnyReadable:readFdArray writable:writeFdArray exception:exceptFdArray withTimeOut:millis
@@ -3996,25 +4014,25 @@
"return true, if filedescriptor can be written without blocking"
self supportsSelect ifFalse:[
- "/ mhmh - what should we do then ?
- "/ For now, return true as if data was present,
- "/ and let the thread fall into the write.
- "/ It will then (hopefully) be desceduled there and
- "/ effectively polling for output.
- ^ true
+ "/ mhmh - what should we do then ?
+ "/ For now, return true as if data was present,
+ "/ and let the thread fall into the write.
+ "/ It will then (hopefully) be desceduled there and
+ "/ effectively polling for output.
+ ^ true
].
(self selectOnAnyReadable:nil
- writable:(Array with:fd)
- exception:nil
- withTimeOut:0) == fd
- ifTrue:[^ true].
+ writable:(Array with:fd)
+ exception:nil
+ withTimeOut:0) == fd
+ ifTrue:[^ true].
^ false
! !
!AbstractOperatingSystem class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/AbstractOperatingSystem.st,v 1.27 1999-10-06 12:10:22 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/AbstractOperatingSystem.st,v 1.28 1999-10-06 12:59:16 ca Exp $'
! !
AbstractOperatingSystem initialize!