public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
From: Cyril Hrubis <chrubis@suse.cz>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH v3.1] lib: add tst_no_corefile()
Date: Thu, 11 Jul 2019 14:34:42 +0200	[thread overview]
Message-ID: <20190711123441.GA8709@rei> (raw)
In-Reply-To: <02ade9af1634c4681156dceecfd51721284044e3.1562591065.git.jstancek@redhat.com>

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

  reply	other threads:[~2019-07-11 12:34 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-05  5:16 [LTP] [PATCH v3] lib: add tst_no_corefile() Li Wang
2019-07-08 13:08 ` [LTP] [PATCH v3.1] " Jan Stancek
2019-07-11 12:34   ` Cyril Hrubis [this message]
2019-07-11 12:45     ` Jan Stancek
2019-07-17  7:47       ` Li Wang
2019-07-17  7:56         ` Jan Stancek
2019-07-15  3:01   ` Li Wang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190711123441.GA8709@rei \
    --to=chrubis@suse.cz \
    --cc=ltp@lists.linux.it \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox