public inbox for linux-man@vger.kernel.org
 help / color / mirror / Atom feed
* [patch] getrlimit.2: fix example program
@ 2011-08-31 14:38 Seonghun Lim
       [not found] ` <4E5E4766.5040500-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
  0 siblings, 1 reply; 2+ messages in thread
From: Seonghun Lim @ 2011-08-31 14:38 UTC (permalink / raw)
  To: mtk.manpages-Re5JQEeQqe8AvxtiuMwx3w; +Cc: linux-man-u79uwXL29TY76Z2rM5mHXA

man-pages version: latest git repository
why: Fix compile error of the example program.
Use struct rlimit instead of rlimit64, which is used in prlimit64().
Make error handling code similar with other examples.


diff --git a/man2/getrlimit.2 b/man2/getrlimit.2
--- a/man2/getrlimit.2
+++ b/man2/getrlimit.2
@@ -529,11 +529,14 @@ The program below demonstrates the use of
#include <unistd.h>
#include <sys/resource.h>

+#define handle_error(msg) \\
+ do { perror(msg); exit(EXIT_FAILURE); } while (0)
+
int
main(int argc, char *argv[])
{
- struct rlimit64 old, new;
- struct rlimit64 *newp;
+ struct rlimit old, new;
+ struct rlimit *newp;
pid_t pid;

if (!(argc == 2 || argc == 4)) {
@@ -555,14 +558,16 @@ main(int argc, char *argv[])
previous limit */

if (prlimit(pid, RLIMIT_CPU, newp, &old) == \-1)
- errExit("prlimit\-1");
+ handle_error("prlimit\-1");
+
printf("Previous limits: soft=%lld; hard=%lld\\n",
(long long) old.rlim_cur, (long long) old.rlim_max);

/* Retrieve and display new CPU time limit */

if (prlimit(pid, RLIMIT_CPU, NULL, &old) == \-1)
- errExit("prlimit\-2");
+ handle_error("prlimit\-2");
+
printf("New limits: soft=%lld; hard=%lld\\n",
(long long) old.rlim_cur, (long long) old.rlim_max);


--
To unsubscribe from this list: send the line "unsubscribe linux-man" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-09-17  5:15 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-08-31 14:38 [patch] getrlimit.2: fix example program Seonghun Lim
     [not found] ` <4E5E4766.5040500-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2011-09-17  5:15   ` Michael Kerrisk

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox