All of lore.kernel.org
 help / color / mirror / Atom feed
From: Cyril Hrubis <chrubis@suse.cz>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH] creat05: count opened fds
Date: Tue, 17 May 2016 16:19:06 +0200	[thread overview]
Message-ID: <20160517141906.GG12051@rei.lan> (raw)
In-Reply-To: <04943ef887b09df79204f36b924dcf753a7b3037.1463488840.git.jstancek@redhat.com>

Hi!
> This testcase estimates number of opened fds by opening
> a new one and assuming there are no gaps. This doesn't always
> hold true. There can be gaps if test harness that runs it
> opens couple fds with O_CLOEXEC prior to starting creat05.
> As result, testcase unexpectedly fails in setup.

As far as I understand it the O_CLOEXEC is not the problem here. It may
be reproduced even without it when the test harness leaves an open fd
after some open one, right?

Something as:

fd0 = open("foo", ...);
fd1 = open("bar", ...);
close(fd0);
fork();
if (!pid)
	exec("creat05");


And in that case the testcase can do even without listing the
/proc/self/fd. Since POSIX specifies that we get the smallest unused fd
for each creat() we can just call it in a loop until the resulting
fd == max_fd - 1. We would have to allocate the array to store the fds
so that we can close them in cleanup though.

-- 
Cyril Hrubis
chrubis@suse.cz

  reply	other threads:[~2016-05-17 14:19 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-17 13:16 [LTP] [PATCH] creat05: count opened fds Jan Stancek
2016-05-17 14:19 ` Cyril Hrubis [this message]
2016-05-17 14:34   ` Jan Stancek

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=20160517141906.GG12051@rei.lan \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.