Bug #11060 ยป 0001-file.c-load-now-supports-reading-from-a-FIFO-file.patch
ChangeLog | ||
---|---|---|
Sat Jun 13 11:46:45 2015 Franck Verrot <franck@verrot.fr>
|
||
file.c : `load` now supports reading from a FIFO file
|
||
* file.c (rb_file_load_ok): `load` can now load not only regular files
|
||
but also FIFOS. [ruby-dev:48924]
|
||
Sat Jun 13 20:28:14 2015 NARUSE, Yui <naruse@ruby-lang.org>
|
||
* file.c (rb_stat_ino): get inode from the interval of struct st.
|
NEWS | ||
---|---|---|
=== Core classes updates (outstanding ones only)
|
||
* Kernel
|
||
* Kernel.load now supports reading from a FIFO file.
|
||
* Enumerable
|
||
* Enumerable#grep_v is added as inverse version of Enumerable#grep.
|
file.c | ||
---|---|---|
#define STAT(p, s) stat((p), (s))
|
||
#endif
|
||
#ifdef S_IFIFO
|
||
# ifndef S_ISFIFO
|
||
# define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO)
|
||
# endif
|
||
#endif
|
||
#if defined(__BEOS__) || defined(__HAIKU__) /* should not change ID if -1 */
|
||
static int
|
||
be_chown(const char *path, uid_t owner, gid_t group)
|
||
... | ... | |
rb_file_pipe_p(VALUE obj, VALUE fname)
|
||
{
|
||
#ifdef S_IFIFO
|
||
# ifndef S_ISFIFO
|
||
# define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO)
|
||
# endif
|
||
struct stat st;
|
||
if (rb_stat(fname, &st) < 0) return Qfalse;
|
||
... | ... | |
rb_update_max_fd(fd);
|
||
#if !defined DOSISH
|
||
{
|
||
struct stat st;
|
||
if (fstat(fd, &st) || !S_ISREG(st.st_mode)) {
|
||
ret = 0;
|
||
}
|
||
struct stat st;
|
||
fstat(fd, &st);
|
||
#ifdef S_IFIFO
|
||
if (!(S_ISREG(st.st_mode) || S_ISFIFO(st.st_mode))) {
|
||
#else
|
||
if (!S_ISREG(st.st_mode)) {
|
||
#endif
|
||
ret = 0;
|
||
}
|
||
}
|
||
#endif
|
||
(void)close(fd);
|
test/ruby/test_require.rb | ||
---|---|---|
end
|
||
end
|
||
def test_load_from_fifo
|
||
bug = '[ruby-dev:48924] #load from a FIFO'
|
||
thread = nil
|
||
Dir.mktmpdir {|tmp|
|
||
file = File.join(tmp,'fifo.rb')
|
||
File.mkfifo(file)
|
||
thread = Thread.new { open(file,'w') { f.puts "puts 1" } }
|
||
assert_separately([], <<-INPUT)
|
||
assert_nothing_raised(LoadError) { load("#{ file }") }
|
||
INPUT
|
||
}
|
||
#thread.join
|
||
end
|
||
def test_tainted_loadpath
|
||
Tempfile.create(["test_ruby_test_require", ".rb"]) {|t|
|
||
abs_dir, file = File.split(t.path)
|