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