17865
|
1 |
"
|
|
2 |
COPYRIGHT (c) 2006 by eXept Software AG
|
|
3 |
All Rights Reserved
|
|
4 |
|
|
5 |
This software is furnished under a license and may be used
|
|
6 |
only in accordance with the terms of that license and with the
|
|
7 |
inclusion of the above copyright notice. This software may not
|
|
8 |
be provided or otherwise made available to, or used by, any
|
|
9 |
other person. No title to or ownership of the software is
|
|
10 |
hereby transferred.
|
|
11 |
"
|
17763
|
12 |
"{ Package: 'stx:libbasic' }"
|
|
13 |
|
|
14 |
Object subclass:#OSProcess
|
|
15 |
instanceVariableNames:'pid parentPid commandLine'
|
|
16 |
classVariableNames:''
|
|
17 |
poolDictionaries:''
|
|
18 |
category:'System-Support'
|
|
19 |
!
|
|
20 |
|
|
21 |
!OSProcess class methodsFor:'documentation'!
|
|
22 |
|
17865
|
23 |
copyright
|
|
24 |
"
|
|
25 |
COPYRIGHT (c) 2006 by eXept Software AG
|
|
26 |
All Rights Reserved
|
|
27 |
|
|
28 |
This software is furnished under a license and may be used
|
|
29 |
only in accordance with the terms of that license and with the
|
|
30 |
inclusion of the above copyright notice. This software may not
|
|
31 |
be provided or otherwise made available to, or used by, any
|
|
32 |
other person. No title to or ownership of the software is
|
|
33 |
hereby transferred.
|
|
34 |
"
|
|
35 |
!
|
|
36 |
|
17763
|
37 |
documentation
|
|
38 |
"
|
|
39 |
OSProcess is an abstract class. Instances represent operating system processes
|
|
40 |
(as opposed to Smalltalk processes).
|
|
41 |
|
|
42 |
[author:]
|
|
43 |
Stefan Vogel (stefan@zwerg)
|
|
44 |
|
|
45 |
[instance variables:]
|
|
46 |
pid SmallInteger the process id
|
|
47 |
parentPid SmallInteger the process id of the parent process
|
|
48 |
commandLine String the command line of the running command.
|
|
49 |
|
|
50 |
[class variables:]
|
|
51 |
|
|
52 |
[see also:]
|
|
53 |
Process
|
|
54 |
|
|
55 |
"
|
|
56 |
! !
|
|
57 |
|
|
58 |
!OSProcess methodsFor:'accessing'!
|
|
59 |
|
|
60 |
commandLine
|
|
61 |
^ commandLine
|
|
62 |
!
|
|
63 |
|
|
64 |
commandLine:something
|
|
65 |
commandLine := something.
|
|
66 |
!
|
|
67 |
|
|
68 |
parentPid
|
|
69 |
^ parentPid
|
|
70 |
!
|
|
71 |
|
|
72 |
parentPid:something
|
|
73 |
parentPid := something.
|
|
74 |
!
|
|
75 |
|
|
76 |
pid
|
|
77 |
^ pid
|
|
78 |
!
|
|
79 |
|
|
80 |
pid:something
|
|
81 |
pid := something.
|
|
82 |
! !
|
|
83 |
|
17834
|
84 |
!OSProcess methodsFor:'printing'!
|
|
85 |
|
|
86 |
printOn:aStream
|
|
87 |
aStream
|
|
88 |
nextPutAll:self className;
|
|
89 |
nextPut:$(.
|
|
90 |
pid printOn:aStream.
|
|
91 |
aStream space.
|
|
92 |
commandLine printOn:aStream.
|
|
93 |
aStream nextPut:$)
|
|
94 |
! !
|
|
95 |
|
17763
|
96 |
!OSProcess methodsFor:'queries'!
|
|
97 |
|
|
98 |
getProcessHandle
|
|
99 |
"some OperatingSystems redefine this to resolve this to a processHandle
|
|
100 |
(which must be explicitely freed later).
|
|
101 |
Others simply return the pid here"
|
|
102 |
|
|
103 |
^ self subclassResponsibility
|
|
104 |
!
|
|
105 |
|
|
106 |
isAlive
|
|
107 |
"answer true, if the process is still alive"
|
|
108 |
|
|
109 |
^ self subclassResponsibility
|
|
110 |
!
|
|
111 |
|
|
112 |
isDead
|
|
113 |
"answer true, if the process is no longer alive"
|
|
114 |
|
|
115 |
^ self isAlive not
|
|
116 |
! !
|
|
117 |
|
|
118 |
!OSProcess methodsFor:'terminating'!
|
|
119 |
|
|
120 |
kill
|
|
121 |
"kill the process - the process does not get the chance to clean up"
|
|
122 |
|
|
123 |
^ self subclassResponsibility.
|
|
124 |
!
|
|
125 |
|
|
126 |
killGroup
|
|
127 |
"killl the processGroup - the processes does not get the chance to clean up"
|
|
128 |
|
|
129 |
^ self subclassResponsibility.
|
|
130 |
!
|
|
131 |
|
|
132 |
killWithAllChildren
|
|
133 |
"terminate gracefully the process with all of its child processes"
|
|
134 |
|
|
135 |
^ self subclassResponsibility.
|
|
136 |
!
|
|
137 |
|
|
138 |
terminate
|
|
139 |
"terminate the process gracefully"
|
|
140 |
|
|
141 |
^ self subclassResponsibility.
|
|
142 |
!
|
|
143 |
|
|
144 |
terminateGroup
|
|
145 |
"terminate the process group.
|
|
146 |
Under Windows, these is the same as terminateWithhAllChildren,
|
|
147 |
under unix, this terminates a subset of all children"
|
|
148 |
|
|
149 |
^ self subclassResponsibility.
|
|
150 |
!
|
|
151 |
|
|
152 |
terminateWithAllChildren
|
|
153 |
"terminate gracefully the process with all of its child processes"
|
|
154 |
|
|
155 |
^ self subclassResponsibility.
|
|
156 |
! !
|
|
157 |
|
|
158 |
!OSProcess class methodsFor:'documentation'!
|
|
159 |
|
|
160 |
version_CVS
|
17845
|
161 |
^ '§Header: /cvs/stx/stx/libbasic/OSProcess.st,v 1.2 2011/03/08 17:01:30 stefan Exp §'
|
17865
|
162 |
!
|
|
163 |
|
|
164 |
version_SVN
|
|
165 |
^ '$Id$'
|
17846
|
166 |
! !
|