All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Theodore Ts'o" <tytso@mit.edu>
To: Tristan Wibberley <tristan.wibberley@gmail.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: New system call wanted: fdreopen
Date: Sun, 9 Dec 2012 11:27:46 -0500	[thread overview]
Message-ID: <20121209162746.GA23890@thunk.org> (raw)
In-Reply-To: <ka2982$ra3$1@ger.gmane.org>

On Sun, Dec 09, 2012 at 03:03:30PM +0000, Tristan Wibberley wrote:
> 
> - /proc/self/fd/* does not solve this problem because the file might no
>   longer be available at the same place in the filesystem. In some
>   otherwise simple message passing or ReSTful IPC a different file will
>   be available at that path.

Actually, /proc/self/fd/* _will_ work.  When you do a ls -l, it looks
like a symlink, but the files in /proc/self/fd (and /proc/<pid>/fd
more generally) are magic.  If you open files in /proc/<pid>/fd/*, it
will do what you want.

See for yourself:

% cat > /tmp/foo.test
foo
bar
^Z
% jobs -l			# (and note the pid, hereafter <pid>)
% ls -l /proc/<pid>/fd 
% mv /tmp/foo.test /tmp/foo2.test
% ls -l /proc/<pid>/fd	# note that the symlink now points at /tmp/foo2.test
% cat /proc/<pid>/fd/1	# note that it works!
% rm /tmp/foo2.test
% ls -l /proc/<pid>/fd	# note that the symlink now has "(deleted)" at the end
% cat /proc/<pid>/fd/1	# note that it works!

This is of course horribly Linux-specific, but so would be a new
system call like your proposed fdrepon.  Better yet, using
/proc/self/fd/* will work *now*.  You don't have to wait for a new
system call in a future verison of the kernel to start shipping in new
distributions.

Regards,

					- Ted

  reply	other threads:[~2012-12-09 16:27 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-09 15:03 New system call wanted: fdreopen Tristan Wibberley
2012-12-09 16:27 ` Theodore Ts'o [this message]
2012-12-09 17:18   ` Tristan Wibberley
2012-12-09 19:37 ` Chris Adams
2012-12-09 20:47   ` Al Viro
2012-12-10 10:18 ` Kevin Easton

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=20121209162746.GA23890@thunk.org \
    --to=tytso@mit.edu \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tristan.wibberley@gmail.com \
    /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.