Debian Codegraph @

man/unix/Sys.ps.Rd

raw
1 \name{Sys.ps}
2 \title{Return Process Status (Unix 'ps') Information}
3 \alias{Sys.ps}
4 %\alias{Sys.ps.cmd}-> now in ../u.sys.Rd
5 \alias{Sys.sizes}
6 \description{
7 These functions return process id and status information, typically
8 about the running \R process.
9 }
10 \usage{
11 Sys.ps(process= Sys.getpid(),
12 fields = c("pid", "pcpu", "time", "vsz", "comm"),
13 usefile = length(fields) > 10,
14 ps.cmd = Sys.ps.cmd(),
15 verbose = getOption("verbose"),
16 warn.multi = verbose || any(fields != "ALL"))
17
18 Sys.sizes(process = Sys.getpid(), ps.cmd = Sys.ps.cmd())
19 }
20 \arguments{
21 \item{process}{the process id, an integer.}
22 \item{fields}{character strings of \code{"ALL"}, specifying which
23 process status fields are desired.}
24 \item{usefile}{logical; if true, \code{\link{system}} writes to a
25 temporary file and that is \code{\link{scan}}ed subsequently.}
26 \item{ps.cmd}{character string, giving the ``ps'' command name to be used.}
27 \item{verbose}{logical ...}
28 \item{warn.multi}{logical ...}
29 }
30 \details{
31 Use \code{man ps} on your respective Unix system, to see what fields are
32 supported exactly. Unix dialects \emph{do} differ here, and,
33 SunOS-Solaris even has more than one ps command\dots
34 %%---- Solaris 2.5.1 man ps has :
35
36 %% DISPLAY FORMATS
37 %% Under the -f option, ps tries to determine the command name
38 %% and arguments given when the process was created by examin-
39 %% ing the user block. Failing this, the command name is
40 %% printed, as it would have appeared without the -f option, in
41 %% square brackets.
42 %%
43 %% The column headings and the meaning of the columns in a ps
44 %% listing are given below; the letters f and l indicate the
45 %% option (full or long, respectively) that causes the
46 %% corresponding heading to appear; all means that the heading
47 %% always appears. Note: These two options determine only
48 %% what information is provided for a process; they do not
49 %% determine which processes will be listed.
50 %%
51 %% F (l) Flags (hexadecimal and additive) associ-
52 %% ated with the process. These flags are
53 %% available for historical purposes; no
54 %% meaning should be currently ascribed to
55 %% them.
56 %%
57 %% S (l) The state of the process:
58 %%
59 %% O Process is running on a processor.
60 %% S Sleeping: process is waiting for an
61 %% event to complete.
62 %% R Runnable: process is on run queue.
63 %% Z Zombie state: process terminated
64 %% and parent not waiting.
65 %% T Process is stopped, either by a job
66 %% control signal or because it is
67 %% being traced.
68 %%
69 %% UID (f,l) The effective user ID number of the pro-
70 %% cess (the login name is printed under
71 %% the -f option).
72 %%
73 %% PID (all) The process ID of the process (this
74 %% datum is necessary in order to kill a
75 %% process).
76 %%
77 %% PPID (f,l) The process ID of the parent process.
78 %%
79 %% C (f,l) Processor utilization for scheduling
80 %% (obsolete). Not printed when the -c
81 %% option is used.
82 %%
83 %% CLS (f,l) Scheduling class. Printed only when the
84 %% -c option is used.
85 %%
86 %% PRI (l) The priority of the process. Without
87 %% the -c option, higher numbers mean lower
88 %% priority. With the -c option, higher
89 %% numbers mean higher priority.
90 %%
91 %% NI (l) Nice value, used in priority computa-
92 %% tion. Not printed when the -c option is
93 %% used. Only processes in the certain
94 %% scheduling classes have a nice value.
95 %%
96 %% ADDR (l) The memory address of the process.
97 %%
98 %% SZ (l) The size (in pages) of the swappable
99 %% process's image in main memory.
100 %%
101 %% WCHAN (l) The address of an event for which the
102 %% process is sleeping (if blank, the pro-
103 %% cess is running).
104 %%
105 %% STIME (f) The starting time of the process, given
106 %% in hours, minutes, and seconds. (A pro-
107 %% cess begun more than twenty-four hours
108 %% before the ps inquiry is executed is
109 %% given in months and days.)
110 %%
111 %% TTY (all) The controlling terminal for the process
112 %% (the message, ?, is printed when there
113 %% is no controlling terminal).
114 %%
115 %% TIME (all) The cumulative execution time for the
116 %% process.
117 %%
118 %% CMD (all) The command name (the full command name
119 %% and its arguments, up to a limit of 80
120 %% characters, are printed under the -f
121 %% option).
122 %%
123 %% The following two additional columns are printed when the -j
124 %% option is specified:
125 %%
126 %% PGID The process ID of the process group
127 %% leader.
128 %%
129 %% SID The process ID of the session leader.
130 %%
131 %% A process that has exited and has a parent, but has not yet
132 %% been waited for by the parent, is marked <defunct>.
133 %%
134 %% -o format
135 %% The -o option allows the output format to be specified under
136 %% user control.
137 %%
138 %% The format specification must be a list of names presented
139 %% as a single argument, blank- or comma-separated. Each vari-
140 %% able has a default header. The default header can be over-
141 %% ridden by appending an equals sign and the new text of the
142 %% header. The rest of the characters in the argument will be
143 %% used as the header text. The fields specified will be writ-
144 %% ten in the order specified on the command line, and should
145 %% be arranged in columns in the output. The field widths will
146 %% be selected by the system to be at least as wide as the
147 %% header text (default or overridden value). If the header
148 %% text is null, such as -o user=, the field width will be at
149 %% least as wide as the default header text. If all header
150 %% text fields are null, no header line will be written.
151 %%
152 %% The following names are recognized in the POSIX locale:
153 %%
154 %% user The effective user ID of the process. This will
155 %% be the textual user ID, if it can be obtained
156 %% and the field width permits, or a decimal
157 %% representation otherwise.
158 %%
159 %% ruser The real user ID of the process. This will be
160 %% the textual user ID, if it can be obtained and
161 %% the field width permits, or a decimal represen-
162 %% tation otherwise.
163 %%
164 %% group The effective group ID of the process. This
165 %% will be the textual group ID, if it can be
166 %% obtained and the field width permits, or a
167 %% decimal representation otherwise.
168 %%
169 %% rgroup The real group ID of the process. This will be
170 %% the textual group ID, if it can be obtained and
171 %% the field width permits, or a decimal represen-
172 %% tation otherwise.
173 %%
174 %% pid The decimal value of the process ID.
175 %%
176 %% ppid The decimal value of the parent process ID.
177 %%
178 %% pgid The decimal value of the process group ID.
179 %%
180 %% pcpu The ratio of CPU time used recently to CPU time
181 %% available in the same period, expressed as a
182 %% percentage. The meaning of ``recently'' in this
183 %% context is unspecified. The CPU time available
184 %% is determined in an unspecified manner.
185 %%
186 %% vsz The size of the process in (virtual) memory in
187 %% kilobytes as a decimal integer.
188 %%
189 %% nice The decimal value of the system scheduling
190 %%
191 %% priority of the process. See nice(1).
192 %%
193 %% etime In the POSIX locale, the elapsed time since the
194 %% process was started, in the form:
195 %% [[dd-]hh:]mm:ss
196 %%
197 %% where
198 %%
199 %% dd will represent the number of days,
200 %% hh the number of hours,
201 %% mm the number of minutes, and
202 %% ss the number of seconds.
203 %%
204 %% The dd field will be a decimal integer. The hh,
205 %% mm and ss fields will be two-digit decimal
206 %% integers padded on the left with zeros.
207 %%
208 %% time In the POSIX locale, the cumulative CPU time of
209 %% the process in the form:
210 %% [dd-]hh:mm:ss
211 %%
212 %% The dd, hh, mm, and ss fields will be as
213 %% described in the etime specifier.
214 %%
215 %% tty The name of the controlling terminal of the pro-
216 %% cess (if any) in the same format used by the
217 %% who(1) command.
218 %%
219 %% comm The name of the command being executed (argv[0]
220 %% value) as a string.
221 %%
222 %% args The command with all its arguments as a string.
223 %% The implementation may truncate this value to
224 %% the field width; it is implementation-dependent
225 %% whether any further truncation occurs. It is
226 %% unspecified whether the string represented is a
227 %% version of the argument list as it was passed to
228 %% the command when it started, or is a version of
229 %% the arguments as they may have been modified by
230 %% the application. Applications cannot depend on
231 %% being able to modify their argument list and
232 %% having that modification be reflected in the
233 %% output of ps. The Solaris implementation limits
234 %% the string to 80 bytes; the string is the ver-
235 %% sion of the argument list as it was passed to
236 %% the command when it started.
237 %%
238 %% The following names are recognized in the Solaris implemen-
239 %% tation:
240 %%
241 %% f Flags (hexadecimal and additive) associated with
242 %% the process.
243 %%
244 %% s The state of the process.
245 %%
246 %% c Processor utilization for scheduling (obsolete).
247 %%
248 %% uid The effective user ID number of the process as a
249 %% decimal integer.
250 %%
251 %% ruid The real user ID number of the process as a
252 %% decimal integer.
253 %%
254 %% gid The effective group ID number of the process as
255 %% a decimal integer.
256 %%
257 %% rgid The real group ID number of the process as a
258 %% decimal integer.
259 %%
260 %% sid The process ID of the session leader.
261 %%
262 %% class The scheduling class of the process.
263 %%
264 %% pri The priority of the process. Higher numbers
265 %% mean higher priority.
266 %%
267 %% opri The obsolete priority of the process. Lower
268 %% numbers mean higher priority.
269 %%
270 %% addr The memory address of the process.
271 %%
272 %% osz The size (in pages) of the swappable process's
273 %% image in main memory.
274 %%
275 %% wchan The address of an event for which the process is
276 %% sleeping (if -, the process is running).
277 %%
278 %% stime The starting time or date of the process,
279 %% printed with no blanks.
280 %%
281 %% rss The resident set size of the process, in kilo-
282 %% bytes as a decimal integer.
283 %%
284 %% pmem The ratio of the process's resident set size to
285 %% the physical memory on the machine, expressed as
286 %% a percentage.
287 %%
288 %% fname The first 8 bytes of the base name of the
289 %% process's executable file.
290 %%
291 %% Only comm and args are allowed to contain blank characters;
292 %% all others, including the Solaris implementation variables,
293 %% are not.
294 %%
295 %% The following table specifies the default header to be used
296 %% in the POSIX locale corresponding to each format specifier.
297 %%
298 %% _______________________________________________________________________
299 %% | Format Specifier Default Header| Format Specifier Default Header|
300 %% |__________________________________|___________________________________|
301 %% | args COMMAND | ppid PPID |
302 %% | comm COMMAND | rgroup RGROUP |
303 %% | etime ELAPSED | ruser RUSER |
304 %% | group GROUP | time TIME |
305 %% | nice NI | tty TT |
306 %% | pcpu %CPU | user USER |
307 %% | pgid PGID | vsz VSZ |
308 %% | pid PID | |
309 %% |__________________________________|___________________________________|
310 %%
311 %% The following table lists the Solaris implementation format
312 %% specifiers and the default header used with each.
313 %%
314 %% _______________________________________________________________________
315 %% | Format Specifier Default Header| Format Specifier Default Header|
316 %% |__________________________________|___________________________________|
317 %% | addr ADDR | pri PRI |
318 %% | c C | rgid RGID |
319 %% | class CLS | rss RSS |
320 %% | f F | ruid RUID |
321 %% | fname COMMAND | s S |
322 %% | gid GID | sid SID |
323 %% | opri PRI | stime STIME |
324 %% | osz SZ | uid UID |
325 %% | pmem %MEM | wchan WCHAN |
326 %% |__________________________________|___________________________________|
327 %%
328
329
330 %%--- Linux man ps has :
331
332 %% STANDARD FORMAT SPECIFIERS
333 %% These may be used to control both output format and sorting.
334 %% For example:
335 %% ps -eo pid,user,args --sort user
336 %%
337 %% CODE HEADER
338 %% ---- ---------
339 %% %cpu %CPU
340 %% %mem %MEM
341 %% alarm ALARM
342 %% args COMMAND
343 %% blocked BLOCKED
344 %% bsdstart START
345 %% bsdtime TIME
346 %% c C
347 %% caught CAUGHT
348 %% cmd CMD
349 %% comm COMMAND
350 %% command COMMAND
351 %% cputime TIME
352 %% drs DRS
353 %% dsiz DSIZ
354 %% egid EGID
355 %% egroup EGROUP
356 %% eip EIP
357 %% esp ESP
358 %% etime ELAPSED
359 %% euid EUID
360 %% euser EUSER
361 %% f F
362 %% fgid FGID
363 %% fgroup FGROUP
364 %% flag F
365 %% flags F
366 %% fname COMMAND
367 %% fsgid FSGID
368 %% fsgroup FSGROUP
369 %% fsuid FSUID
370 %% fsuser FSUSER
371 %% fuid FUID
372 %% fuser FUSER
373 %% gid GID
374 %% group GROUP
375 %% ignored IGNORED
376 %% intpri PRI
377 %% lim LIM
378 %% longtname TTY
379 %% lstart STARTED
380 %% m_drs DRS
381 %% m_trs TRS
382 %% maj_flt MAJFL
383 %% majflt MAJFLT
384 %% min_flt MINFL
385 %% minflt MINFLT
386 %% ni NI
387 %% nice NI
388 %% nwchan WCHAN
389 %% opri PRI
390 %% pagein PAGEIN
391 %% pcpu %CPU
392 %% pending PENDING
393 %% pgid PGID
394 %% pgrp PGRP
395 %% pid PID
396 %% pmem %MEM
397 %% ppid PPID
398 %% pri PRI
399 %% rgid RGID
400 %% rgroup RGROUP
401 %% rss RSS
402 %% rssize RSS
403 %% rsz RSZ
404 %% ruid RUID
405 %% ruser RUSER
406 %% s S
407 %% sess SESS
408 %% session SESS
409 %% sgi_p P
410 %% sgi_rss RSS
411 %% sgid SGID
412 %% sgroup SGROUP
413 %% sid SID
414 %% sig PENDING
415 %% sig_block BLOCKED
416 %% sig_catch CATCHED
417 %% sig_ignore IGNORED
418 %% sig_pend SIGNAL
419 %% sigcatch CAUGHT
420 %% sigignore IGNORED
421 %% sigmask BLOCKED
422 %% stackp STACKP
423 %% start STARTED
424 %% start_stack STACKP
425 %% start_time START
426 %% stat STAT
427 %% state S
428 %% stime STIME
429 %% suid SUID
430 %% suser SUSER
431 %% svgid SVGID
432 %% svgroup SVGROUP
433 %% svuid SVUID
434 %% svuser SVUSER
435 %% sz SZ
436 %% time TIME
437 %% timeout TMOUT
438 %% tmout TMOUT
439 %% tname TTY
440 %% tpgid TPGID
441 %% trs TRS
442 %% trss TRSS
443 %% tsiz TSIZ
444 %% tt TT
445 %% tty TT
446 %% tty4 TTY
447 %% tty8 TTY
448 %% ucomm COMMAND
449 %% uid UID
450 %% uid_hack UID
451 %% uname USER
452 %% user USER
453 %% vsize VSZ
454 %% vsz VSZ
455 %% wchan WCHAN
456
457 %%------------------------------------
458 %%
459 }
460 \value{
461 Note, that \code{Sys.sizes()} currently returns two integers which are
462 ``common'' to Solaris and Linux.
463 }
464 \author{Martin Maechler}
465 \seealso{\code{\link{Sys.info}}, \code{\link{Sys.getpid}},
466 \code{\link{proc.time}}.
467 }
468 \examples{
469 (.pid <- Sys.getpid()) ## process ID of current process
470 try( Sys.sizes(.pid) )
471 #^^ fails on Alpine Linux: https://github.com/mmaechler/sfsmisc/issues/9
472
473 ## The default process statistics about the running R process
474 try( Sys.ps() )
475 }
476 \keyword{utilities}