1explain_getrusage_or_die(3)Library Functions Manualexplain_getrusage_or_die(3)
2
3
4
6 explain_getrusage_or_die - get resource usage and report errors
7
9 #include <libexplain/getrusage.h>
10 void explain_getrusage_or_die(int who, struct rusage *usage);
11 int explain_getrusage_on_error(int who, struct rusage *usage);
12
14 The explain_getrusage_or_die function is used to call the getrusage(2)
15 system call. On failure an explanation will be printed to stderr,
16 obtained from the explain_getrusage(3) function, and then the process
17 terminates by calling exit(EXIT_FAILURE).
18
19 The explain_getrusage_on_error function is used to call the
20 getrusage(2) system call. On failure an explanation will be printed to
21 stderr, obtained from the explain_getrusage(3) function, but still
22 returns to the caller.
23
24 who The who, exactly as to be passed to the getrusage(2) system
25 call.
26
27 usage The usage, exactly as to be passed to the getrusage(2) system
28 call.
29
31 The explain_getrusage_or_die function only returns on success, see
32 getrusage(2) for more information. On failure, prints an explanation
33 and exits, it does not return.
34
35 The explain_getrusage_on_error function always returns the value return
36 by the wrapped getrusage(2) system call.
37
39 The explain_getrusage_or_die function is intended to be used in a fash‐
40 ion similar to the following example:
41 explain_getrusage_or_die(who, usage);
42
44 getrusage(2)
45 get resource usage
46
47 explain_getrusage(3)
48 explain getrusage(2) errors
49
50 exit(2) terminate the calling process
51
53 libexplain version 1.4
54 Copyright (C) 2013 Peter Miller
55
56
57
58 explain_getrusage_or_die(3)