Skip to content

Commit f20fadd

Browse files
committed
Solve malloc failure when starting atopsar for live measurement
Only lock memory when the memory limit was successfully set to unlimited.
1 parent 573cba4 commit f20fadd

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

atopsar.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -369,8 +369,9 @@ atopsar(int argc, char *argv[])
369369
*/
370370
rlim.rlim_cur = RLIM_INFINITY;
371371
rlim.rlim_max = RLIM_INFINITY;
372-
(void) setrlimit(RLIMIT_MEMLOCK, &rlim);
373-
(void) mlockall(MCL_CURRENT|MCL_FUTURE);
372+
373+
if (setrlimit(RLIMIT_MEMLOCK, &rlim) == 0)
374+
(void) mlockall(MCL_CURRENT|MCL_FUTURE);
374375

375376
/*
376377
** increment CPU scheduling-priority to get reliable samples (also

0 commit comments

Comments
 (0)