[LTP] [PATCH v3.1] lib: add tst_no_corefile()
Cyril Hrubis
chrubis@suse.cz
Thu Jul 11 14:34:42 CEST 2019
Hi!
> +void tst_no_corefile(int verbose)
> +{
> + struct rlimit new_r, old_r;
> +
> + SAFE_GETRLIMIT(RLIMIT_CORE, &old_r);
> + if (old_r.rlim_max >= 1 || geteuid() == 0) {
> + /*
> + * 1 is a special value, that disables core-to-pipe.
> + * At the same time it is small enough value for
> + * core-to-file, so it skips creating cores as well.
> + */
> + new_r.rlim_cur = 1;
> + new_r.rlim_max = 1;
> + SAFE_SETRLIMIT(RLIMIT_CORE, &new_r);
> + }
> +
> + if (verbose)
> + tst_res(TINFO, "Avoid dumping corefile for process(pid=%d)", getpid());
Should we print the message here only
if (old_r.rlim_max <= 1 || geteuid() == 0)
because otherwise we will print the mesasge even in cases that the
corefile is not in fact limited.
--
Cyril Hrubis
chrubis@suse.cz
More information about the ltp
mailing list