class: UnixOperatingSystem
changed:
#closeLeftOverFiles
#pathNameOf:
use new copyButLast
--- a/UnixOperatingSystem.st Fri Jul 04 12:26:35 2014 +0200
+++ b/UnixOperatingSystem.st Fri Jul 04 12:26:55 2014 +0200
@@ -5120,66 +5120,66 @@
|p path command|
path = '.' ifTrue:[
- ^ self getCurrentDirectory.
+ ^ self getCurrentDirectory.
].
"some systems have a convenient function for this ..."
path := self primPathNameOf:(self encodePath:pathName).
path notNil ifTrue:[
- path := self decodePath:path.
+ path := self decodePath:path.
] ifFalse:[
- (self isValidPath:pathName) ifFalse:[
- p := pathName.
- [(p size > 1)
- and:[p endsWith:(self fileSeparator)]
- ] whileTrue:[
- p := p copyButLast:1.
- ].
- ^ p
- ].
-
- (SlowFork==true or:[PipeFailed==true]) ifFalse:[
- |directoryName fileBaseName|
-
- (self isDirectory:pathName) ifTrue:[
- directoryName := pathName.
- fileBaseName := nil.
- ] ifFalse:[
- |pathFilename|
- pathFilename := pathName asFilename.
- directoryName := pathFilename directoryName.
- fileBaseName := pathFilename baseName.
- ].
-
- PipeStream openErrorSignal handle:[:ex |
- PipeFailed := true.
- 'UnixOperatingSystem [warning]: cannot fork/popen' errorPrintCR.
- ex return.
- ] do:[
- "have to fall back ..."
- command := 'cd "' , directoryName , '"; pwd'.
- p := PipeStream readingFrom:command.
- ].
-
- (p isNil or:[p atEnd]) ifTrue:[
- ('UnixOperatingSystem [warning]: PipeStream for <' , command , '> failed') errorPrintCR.
- ] ifFalse:[
- path := p nextLine.
- p close.
- ].
- fileBaseName notNil ifTrue:[
- path := path, '/', fileBaseName.
- ].
- ].
- path isNil ifTrue:[
- "/
- "/ return the original - there is nothing else can we do
- "/
- path := pathName
- ].
- (SlowFork==true or:[ForkFailed==true]) ifTrue:[
- path := self compressPath:path
- ]
+ (self isValidPath:pathName) ifFalse:[
+ p := pathName.
+ [(p size > 1)
+ and:[p endsWith:(self fileSeparator)]
+ ] whileTrue:[
+ p := p copyButLast.
+ ].
+ ^ p
+ ].
+
+ (SlowFork==true or:[PipeFailed==true]) ifFalse:[
+ |directoryName fileBaseName|
+
+ (self isDirectory:pathName) ifTrue:[
+ directoryName := pathName.
+ fileBaseName := nil.
+ ] ifFalse:[
+ |pathFilename|
+ pathFilename := pathName asFilename.
+ directoryName := pathFilename directoryName.
+ fileBaseName := pathFilename baseName.
+ ].
+
+ PipeStream openErrorSignal handle:[:ex |
+ PipeFailed := true.
+ 'UnixOperatingSystem [warning]: cannot fork/popen' errorPrintCR.
+ ex return.
+ ] do:[
+ "have to fall back ..."
+ command := 'cd "' , directoryName , '"; pwd'.
+ p := PipeStream readingFrom:command.
+ ].
+
+ (p isNil or:[p atEnd]) ifTrue:[
+ ('UnixOperatingSystem [warning]: PipeStream for <' , command , '> failed') errorPrintCR.
+ ] ifFalse:[
+ path := p nextLine.
+ p close.
+ ].
+ fileBaseName notNil ifTrue:[
+ path := path, '/', fileBaseName.
+ ].
+ ].
+ path isNil ifTrue:[
+ "/
+ "/ return the original - there is nothing else can we do
+ "/
+ path := pathName
+ ].
+ (SlowFork==true or:[ForkFailed==true]) ifTrue:[
+ path := self compressPath:path
+ ]
].
^ path.
@@ -6509,36 +6509,36 @@
closeLeftOverFiles
"a bad bad kludge and workaround for a big bug in the linux
getAddrInfo implementation:
- if it gets interrupted (via a timer, for example), its domain-name
- socket remains open and is NEVER closed.
- These open files collect up and lead to no-more-files eventually.
+ if it gets interrupted (via a timer, for example), its domain-name
+ socket remains open and is NEVER closed.
+ These open files collect up and lead to no-more-files eventually.
Invoking this method helps in this situation."
|p|
p := PipeStream
- readingFrom:('lsof -p ' , (OperatingSystem getProcessId printString)).
+ readingFrom:('lsof -p ' , (OperatingSystem getProcessId printString)).
p linesDo:[:line |
- |words fd|
-
- words := line asCollectionOfWords.
- "/ COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME
- words first = 'stx' ifTrue:[
- words second = (OperatingSystem getProcessId printString) ifTrue:[
- (words fourth endsWith:'u') ifTrue:[
- (words fifth = 'IPv4') ifTrue:[
- (words seventh = 'UDP') ifTrue:[
- (words last endsWith:'domain') ifTrue:[
- fd := Number readFrom:(words fourth copyButLast:1).
+ |words fd|
+
+ words := line asCollectionOfWords.
+ "/ COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME
+ words first = 'stx' ifTrue:[
+ words second = (OperatingSystem getProcessId printString) ifTrue:[
+ (words fourth endsWith:'u') ifTrue:[
+ (words fifth = 'IPv4') ifTrue:[
+ (words seventh = 'UDP') ifTrue:[
+ (words last endsWith:'domain') ifTrue:[
+ fd := Number readFrom:(words fourth copyButLast).
Transcript showCR:line.
- OperatingSystem closeFd:fd.
- ]
- ]
- ]
- ]
- ]
- ]
+ OperatingSystem closeFd:fd.
+ ]
+ ]
+ ]
+ ]
+ ]
+ ]
].
p close.
@@ -13308,11 +13308,11 @@
!UnixOperatingSystem class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/UnixOperatingSystem.st,v 1.377 2014-07-03 14:36:25 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/UnixOperatingSystem.st,v 1.378 2014-07-04 10:26:55 cg Exp $'
!
version_CVS
- ^ '$Header: /cvs/stx/stx/libbasic/UnixOperatingSystem.st,v 1.377 2014-07-03 14:36:25 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/UnixOperatingSystem.st,v 1.378 2014-07-04 10:26:55 cg Exp $'
! !