[patch] getrlimit.2: fix example program

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Kernel Documentation]     [Netdev]     [Linux Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux