@@ -1100,3 +1100,36 @@ pub fn lchown<P: AsRef<Path>>(dir: P, uid: Option<u32>, gid: Option<u32>) -> io:
1100
1100
pub fn chroot < P : AsRef < Path > > ( dir : P ) -> io:: Result < ( ) > {
1101
1101
sys:: fs:: chroot ( dir. as_ref ( ) )
1102
1102
}
1103
+
1104
+ /// Create fifo at the specified path with the specified mode.
1105
+ ///
1106
+ /// # Examples
1107
+ ///
1108
+ /// ```
1109
+ /// # #![feature(unix_mkfifo)]
1110
+ /// # use std::{
1111
+ /// # os::unix::fs::{mkfifo, PermissionsExt},
1112
+ /// # fs::{File, Permissions, remove_file},
1113
+ /// # io::{Write, Read},
1114
+ /// # };
1115
+ /// # fn main() -> std::io::Result<()> {
1116
+ /// # remove_file("/tmp/fifo")?;
1117
+ /// mkfifo("/tmp/fifo", Permissions::from_mode(0o774))?;
1118
+ ///
1119
+ /// let mut wx = File::options().read(true).write(true).open("/tmp/fifo")?;
1120
+ /// let mut rx = File::open("/tmp/fifo")?;
1121
+ ///
1122
+ /// wx.write_all(b"hello, world!")?;
1123
+ /// drop(wx);
1124
+ ///
1125
+ /// let mut s = String::new();
1126
+ /// rx.read_to_string(&mut s)?;
1127
+ ///
1128
+ /// assert_eq!(s, "hello, world!");
1129
+ /// # Ok(())
1130
+ /// # }
1131
+ /// ```
1132
+ #[ unstable( feature = "unix_mkfifo" , issue = "139324" ) ]
1133
+ pub fn mkfifo < P : AsRef < Path > > ( path : P , permissions : Permissions ) -> io:: Result < ( ) > {
1134
+ sys:: fs:: mkfifo ( path. as_ref ( ) , permissions. mode ( ) )
1135
+ }
0 commit comments