1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
|
package OS2::Process;
$VERSION = 0.2;
require Exporter;
require DynaLoader;
#require AutoLoader;
@ISA = qw(Exporter DynaLoader);
# Items to export into callers namespace by default. Note: do not export
# names by default without a very good reason. Use EXPORT_OK instead.
# Do not simply export all your public functions/methods/constants.
@EXPORT = qw(
P_BACKGROUND
P_DEBUG
P_DEFAULT
P_DETACH
P_FOREGROUND
P_FULLSCREEN
P_MAXIMIZE
P_MINIMIZE
P_NOCLOSE
P_NOSESSION
P_NOWAIT
P_OVERLAY
P_PM
P_QUOTE
P_SESSION
P_TILDE
P_UNRELATED
P_WAIT
P_WINDOWED
my_type
file_type
T_NOTSPEC
T_NOTWINDOWCOMPAT
T_WINDOWCOMPAT
T_WINDOWAPI
T_BOUND
T_DLL
T_DOS
T_PHYSDRV
T_VIRTDRV
T_PROTDLL
T_32BIT
process_entry
set_title
get_title
);
sub AUTOLOAD {
# This AUTOLOAD is used to 'autoload' constants from the constant()
# XS function. If a constant is not found then control is passed
# to the AUTOLOAD in AutoLoader.
local($constname);
($constname = $AUTOLOAD) =~ s/.*:://;
$val = constant($constname, @_ ? $_[0] : 0);
if ($! != 0) {
if ($! =~ /Invalid/ || $!{EINVAL}) {
$AutoLoader::AUTOLOAD = $AUTOLOAD;
goto &AutoLoader::AUTOLOAD;
}
else {
($pack,$file,$line) = caller;
die "Your vendor has not defined OS2::Process macro $constname, used at $file line $line.
";
}
}
eval "sub $AUTOLOAD { $val }";
goto &$AUTOLOAD;
}
bootstrap OS2::Process;
# Preloaded methods go here.
sub get_title () { (process_entry())[0] }
# Autoload methods go after __END__, and are processed by the autosplit program.
1;
__END__
=head1 NAME
OS2::Process - exports constants for system() call on OS2.
=head1 SYNOPSIS
use OS2::Process;
$pid = system(P_PM+P_BACKGROUND, "epm.exe");
=head1 DESCRIPTION
the builtin function system() under OS/2 allows an optional first
argument which denotes the mode of the process. Note that this argument is
recognized only if it is strictly numerical.
You can use either one of the process modes:
P_WAIT (0) = wait until child terminates (default)
P_NOWAIT = do not wait until child terminates
P_SESSION = new session
P_DETACH = detached
P_PM = PM program
and optionally add PM and session option bits:
P_DEFAULT (0) = default
P_MINIMIZE = minimized
P_MAXIMIZE = maximized
P_FULLSCREEN = fullscreen (session only)
P_WINDOWED = windowed (session only)
P_FOREGROUND = foreground (if running in foreground)
P_BACKGROUND = background
P_NOCLOSE = don't close window on exit (session only)
P_QUOTE = quote all arguments
P_TILDE = MKS argument passing convention
P_UNRELATED = do not kill child when father terminates
=head2 Access to process properties
Additionaly, subroutines my_type(), process_entry() and
C<file_type(file)>, get_title() and C<set_title(newtitle)> are implemented.
my_type() returns the type of the current process (one of
"FS", "DOS", "VIO", "PM", "DETACH" and "UNKNOWN"), or C<undef> on error.
=over
=item C<file_type(file)>
returns the type of the executable file C<file>, or
dies on error. The bits 0-2 of the result contain one of the values
=over
=item C<T_NOTSPEC> (0)
Application type is not specified in the executable header.
=item C<T_NOTWINDOWCOMPAT> (1)
Application type is not-window-compatible.
=item C<T_WINDOWCOMPAT> (2)
Application type is window-compatible.
=item C<T_WINDOWAPI> (3)
Application type is window-API.
=back
The remaining bits should be masked with the following values to
determine the type of the executable:
=over
=item C<T_BOUND> (8)
Set to 1 if the executable file has been "bound" (by the BIND command)
as a Family API application. Bits 0, 1, and 2 still apply.
=item C<T_DLL> (0x10)
Set to 1 if the executable file is a dynamic link library (DLL)
module. Bits 0, 1, 2, 3, and 5 will be set to 0.
=item C<T_DOS> (0x20)
Set to 1 if the executable file is in PC/DOS format. Bits 0, 1, 2, 3,
and 4 will be set to 0.
=item C<T_PHYSDRV> (0x40)
Set to 1 if the executable file is a physical device driver.
=item C<T_VIRTDRV> (0x80)
Set to 1 if the executable file is a virtual device driver.
=item C<T_PROTDLL> (0x100)
Set to 1 if the executable file is a protected-memory dynamic link
library module.
=item C<T_32BIT> (0x4000)
Set to 1 for 32-bit executable files.
=back
file_type() may croak with one of the strings C<"Invalid EXE
signature"> or C<"EXE marked invalid"> to indicate typical error
conditions. If given non-absolute path, will look on C<PATH>, will
add extention F<.exe> if no extension is present (add extension F<.>
to suppress).
=item process_entry()
returns a list of the following data:
=over
=item
Title of the process (in the C<Ctrl-Esc> list);
=item
window handle of switch entry of the process (in the C<Ctrl-Esc> list);
=item
window handle of the icon of the process;
=item
process handle of the owner of the entry in C<Ctrl-Esc> list;
=item
process id of the owner of the entry in C<Ctrl-Esc> list;
=item
session id of the owner of the entry in C<Ctrl-Esc> list;
=item
whether visible in C<Ctrl-Esc> list;
=item
whether item cannot be switched to (note that it is not actually
grayed in the C<Ctrl-Esc> list));
=item
whether participates in jump sequence;
=item
program type. Possible values are:
PROG_DEFAULT 0
PROG_FULLSCREEN 1
PROG_WINDOWABLEVIO 2
PROG_PM 3
PROG_VDM 4
PROG_WINDOWEDVDM 7
Although there are several other program types for WIN-OS/2 programs,
these do not show up in this field. Instead, the PROG_VDM or
PROG_WINDOWEDVDM program types are used. For instance, for
PROG_31_STDSEAMLESSVDM, PROG_WINDOWEDVDM is used. This is because all
the WIN-OS/2 programs run in DOS sessions. For example, if a program
is a windowed WIN-OS/2 program, it runs in a PROG_WINDOWEDVDM
session. Likewise, if it's a full-screen WIN-OS/2 program, it runs in
a PROG_VDM session.
=back
=item C<set_title(newtitle)>
- does not work with some windows (if the title is set from the start).
This is a limitation of OS/2, in such a case $^E is set to 372 (type
help 372
for a funny - and wrong - explanation ;-).
=item get_title()
is a shortcut implemented via process_entry().
=back
=head1 AUTHOR
Andreas Kaiser <ak@ananke.s.bawue.de>,
Ilya Zakharevich <ilya@math.ohio-state.edu>.
=head1 SEE ALSO
C<spawn*>() system calls.
=cut
|