Skip to content

Commit 06ec31d

Browse files
authored
Merge pull request #79 from shoshanatech/image-portability
Better support for moving images between Windows and Linux (fixes #78)
2 parents f4c1da6 + 116c972 commit 06ec31d

File tree

2 files changed

+32
-47
lines changed

2 files changed

+32
-47
lines changed

repository/OSSubprocess/OSSUnixSubprocess.class.st

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,16 @@ Class {
6868
#category : #OSSubprocess
6969
}
7070

71+
{ #category : #'temp files' }
72+
OSSUnixSubprocess class >> createTempFilename [
73+
"Read comment of createTempFileToBeUsedAsReadStreamOn:.
74+
75+
This answers just ONE WAY of defining a temp filename"
76+
77+
^ self name , '-p', OSSVMProcess vmProcess pid asString, '-', UUID new printString, '.deleteme'
78+
79+
]
80+
7181
{ #category : #'temp files' }
7282
OSSUnixSubprocess class >> createTempFileToBeUsedAsReadStreamOn: aDirectoryPath [
7383
"Important: for some reason, if we use MultiByteFileStream instances, we have some test failures.
@@ -90,16 +100,6 @@ OSSUnixSubprocess class >> createTempFileToBeUsedAsWriteStreamOn: aDirectoryPath
90100
^ OldStandardFileStream forceNewFileNamed: (aDirectoryPath asFileReference / self createTempFilename) fullName
91101
]
92102

93-
{ #category : #'temp files' }
94-
OSSUnixSubprocess class >> createTempFilename [
95-
"Read comment of createTempFileToBeUsedAsReadStreamOn:.
96-
97-
This answers just ONE WAY of defining a temp filename"
98-
99-
^ self name , '-p', OSSVMProcess vmProcess pid asString, '-', UUID new printString, '.deleteme'
100-
101-
]
102-
103103
{ #category : #'env building' }
104104
OSSUnixSubprocess >> addAllEnvVariablesFromParentWithoutOverride [
105105
"The user may have done an explicit set of a variable via #environmentAt:put: in which case

repository/OSSubprocess/OSSVMProcess.class.st

Lines changed: 22 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -30,33 +30,24 @@ Class {
3030
'LibCErrnoSharedPool',
3131
'LibCWaitSharedPool'
3232
],
33-
#category : 'OSSubprocess'
33+
#category : #OSSubprocess
3434
}
3535

3636
{ #category : #'initialize - release' }
3737
OSSVMProcess class >> initialize [
38-
Smalltalk os isWindows ifTrue: [ ^ self ]. "Cannot be initialized nor used on Windows."
39-
40-
self initializeVMProcessInstance.
41-
self flag: #removeIt.
42-
"This IF will be eliminated soon...only here temporary"
43-
(SystemVersion current highestUpdate >= 50558)
44-
ifTrue: [
45-
SessionManager default registerToolClassNamed: self name
46-
]
47-
ifFalse: [
48-
Smalltalk addToStartUpList: OSSVMProcess.
49-
Smalltalk addToShutDownList: OSSVMProcess.
50-
]
51-
38+
39+
self initializeVMProcessInstance.
40+
SessionManager default registerToolClassNamed: self name
5241
]
5342

5443
{ #category : #'initialize - release' }
5544
OSSVMProcess class >> initializeVMProcessInstance [
56-
VMProcess isNil
57-
ifTrue: [ VMProcess := self basicNew. ]
58-
ifFalse: [ VMProcess finalizePreviousSession ].
59-
VMProcess initialize.
45+
46+
VMProcess ifNotNil: [
47+
VMProcess finalizePreviousSession.
48+
VMProcess := nil ].
49+
Smalltalk os isWindows ifFalse: [
50+
VMProcess := self basicNew initialize ]
6051
]
6152

6253
{ #category : #'instance creation' }
@@ -73,18 +64,8 @@ OSSVMProcess class >> shutDown: quitting [
7364

7465
{ #category : #'system startup' }
7566
OSSVMProcess class >> startUp: resuming [
76-
77-
resuming ifTrue: [
78-
"To understand why the #stopWaiting, first read the comment of
79-
OSSVMProcess shutDown:
80-
It could happen that when the shutDown happened, the child process
81-
was in the wait of #waitForExitPollingEvery:doing:. Therefore, until the
82-
next cycle of the loop it won't do the queryExitStatus. So we may still
83-
have this problem in image startup. So just in case we run it too in the startup code.
84-
"
85-
self vmProcess activeChildren do: [ :each | each stopWaiting ].
86-
self initializeVMProcessInstance.
87-
]
67+
68+
resuming ifTrue: [ self initializeVMProcessInstance ]
8869
]
8970

9071
{ #category : #'OS Process' }
@@ -187,15 +168,19 @@ OSSVMProcess >> finalizePreviousSession [
187168
"This method is likely called at image startup and it's job is to finalize
188169
stuff related to the previous run and let everything clean so that
189170
the unique instance vmProcess of OSSVMProcess can be initialized correctly at startup. "
190-
childWatcher ifNotNil: [
171+
172+
childWatcher ifNotNil: [
191173
childWatcher isTerminated ifFalse: [ childWatcher terminate ].
192-
childWatcher := nil.
193-
].
174+
childWatcher := nil ].
194175
sigChldSemaphore ifNotNil: [
195176
self systemAccessor restoreSigChld.
196-
sigChldSemaphore := nil
197-
]
198-
177+
sigChldSemaphore := nil ].
178+
"To understand why the #stopWaiting, first read the comment of #shutDown:.
179+
It could happen that when the shutDown happened, the child process was in
180+
the wait of #waitForExitPollingEvery:doing:. Therefore, until the next cycle
181+
of the loop it won't do the queryExitStatus. So we may still have this
182+
problem in image startup. So just in case we run it too in the startup code."
183+
self activeChildren do: [ :each | each stopWaiting ]
199184
]
200185

201186
{ #category : #'initialize - release' }

0 commit comments

Comments
 (0)