12890
|
1 |
"{ Package: 'stx:libbasic' }"
|
|
2 |
|
|
3 |
Object subclass:#OSProcess
|
|
4 |
instanceVariableNames:'pid parentPid commandLine'
|
|
5 |
classVariableNames:''
|
|
6 |
poolDictionaries:''
|
|
7 |
category:'System-Support'
|
|
8 |
!
|
|
9 |
|
|
10 |
!OSProcess class methodsFor:'documentation'!
|
|
11 |
|
|
12 |
documentation
|
|
13 |
"
|
|
14 |
OSProcess is an abstract class. Instances represent operating system processes
|
|
15 |
(as opposed to Smalltalk processes).
|
|
16 |
|
|
17 |
[author:]
|
|
18 |
Stefan Vogel (stefan@zwerg)
|
|
19 |
|
|
20 |
[instance variables:]
|
|
21 |
pid SmallInteger the process id
|
|
22 |
parentPid SmallInteger the process id of the parent process
|
|
23 |
commandLine String the command line of the running command.
|
|
24 |
|
|
25 |
[class variables:]
|
|
26 |
|
|
27 |
[see also:]
|
|
28 |
Process
|
|
29 |
|
|
30 |
"
|
|
31 |
! !
|
|
32 |
|
|
33 |
!OSProcess methodsFor:'accessing'!
|
|
34 |
|
|
35 |
commandLine
|
|
36 |
^ commandLine
|
|
37 |
!
|
|
38 |
|
|
39 |
commandLine:something
|
|
40 |
commandLine := something.
|
|
41 |
!
|
|
42 |
|
|
43 |
parentPid
|
|
44 |
^ parentPid
|
|
45 |
!
|
|
46 |
|
|
47 |
parentPid:something
|
|
48 |
parentPid := something.
|
|
49 |
!
|
|
50 |
|
|
51 |
pid
|
|
52 |
^ pid
|
|
53 |
!
|
|
54 |
|
|
55 |
pid:something
|
|
56 |
pid := something.
|
|
57 |
! !
|
|
58 |
|
13313
|
59 |
!OSProcess methodsFor:'printing'!
|
|
60 |
|
|
61 |
printOn:aStream
|
|
62 |
aStream
|
|
63 |
nextPutAll:self className;
|
|
64 |
nextPut:$(.
|
|
65 |
pid printOn:aStream.
|
|
66 |
aStream space.
|
|
67 |
commandLine printOn:aStream.
|
|
68 |
aStream nextPut:$)
|
|
69 |
! !
|
|
70 |
|
12890
|
71 |
!OSProcess methodsFor:'queries'!
|
|
72 |
|
|
73 |
getProcessHandle
|
|
74 |
"some OperatingSystems redefine this to resolve this to a processHandle
|
|
75 |
(which must be explicitely freed later).
|
|
76 |
Others simply return the pid here"
|
|
77 |
|
|
78 |
^ self subclassResponsibility
|
|
79 |
!
|
|
80 |
|
|
81 |
isAlive
|
|
82 |
"answer true, if the process is still alive"
|
|
83 |
|
|
84 |
^ self subclassResponsibility
|
|
85 |
!
|
|
86 |
|
|
87 |
isDead
|
|
88 |
"answer true, if the process is no longer alive"
|
|
89 |
|
|
90 |
^ self isAlive not
|
|
91 |
! !
|
|
92 |
|
|
93 |
!OSProcess methodsFor:'terminating'!
|
|
94 |
|
|
95 |
kill
|
|
96 |
"kill the process - the process does not get the chance to clean up"
|
|
97 |
|
|
98 |
^ self subclassResponsibility.
|
|
99 |
!
|
|
100 |
|
|
101 |
killGroup
|
|
102 |
"killl the processGroup - the processes does not get the chance to clean up"
|
|
103 |
|
|
104 |
^ self subclassResponsibility.
|
|
105 |
!
|
|
106 |
|
|
107 |
killWithAllChildren
|
|
108 |
"terminate gracefully the process with all of its child processes"
|
|
109 |
|
|
110 |
^ self subclassResponsibility.
|
|
111 |
!
|
|
112 |
|
|
113 |
terminate
|
|
114 |
"terminate the process gracefully"
|
|
115 |
|
|
116 |
^ self subclassResponsibility.
|
|
117 |
!
|
|
118 |
|
|
119 |
terminateGroup
|
|
120 |
"terminate the process group.
|
|
121 |
Under Windows, these is the same as terminateWithhAllChildren,
|
|
122 |
under unix, this terminates a subset of all children"
|
|
123 |
|
|
124 |
^ self subclassResponsibility.
|
|
125 |
!
|
|
126 |
|
|
127 |
terminateWithAllChildren
|
|
128 |
"terminate gracefully the process with all of its child processes"
|
|
129 |
|
|
130 |
^ self subclassResponsibility.
|
|
131 |
! !
|
|
132 |
|
|
133 |
!OSProcess class methodsFor:'documentation'!
|
|
134 |
|
|
135 |
version_CVS
|
13313
|
136 |
^ '$Header: /cvs/stx/stx/libbasic/OSProcess.st,v 1.2 2011-03-08 17:01:30 stefan Exp $'
|
12890
|
137 |
! !
|