[LTP] [PATCH v3.1] lib: add tst_no_corefile()

Jan Stancek jstancek@redhat.com
Thu Jul 11 14:45:36 CEST 2019



----- Original Message -----
> 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.

Depends on setup of core_pattern, if it's core-to-file it's already limited.
If it's core-to-pipe, then it's no limit, so I agree, we can move it above.

> 
> --
> Cyril Hrubis
> chrubis@suse.cz
> 


More information about the ltp mailing list