Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →
class method
File.mkfifo
(::path file_name, ?::int mode) -> 0
File.mkfifo(path, mode = 0666) → 0
file.c
View on GitHub ↗
static VALUE
rb_file_s_mkfifo(int argc, VALUE *argv, VALUE _)
{
VALUE path;
struct mkfifo_arg ma;
ma.mode = 0666;
rb_check_arity(argc, 1, 2);
if (argc > 1) {
ma.mode = NUM2MODET(argv[1]);
}
path = argv[0];
FilePathValue(path);
path = rb_str_encode_ospath(path);
ma.path = RSTRING_PTR(path);
if (IO_WITHOUT_GVL(nogvl_mkfifo, &ma)) {
rb_sys_fail_path(path);
}
return INT2FIX(0);
}
Creates a FIFO special file at the given path, with the permissions given by mode; see Filesystem Modes:
Example
path = '/tmp/pipe' File.mkfifo(path) File.pipe?(path) # => true File.ftype(path) # => "fifo" File.unlink(path)
Not implemented on Windows.