@@ -814,9 +814,10 @@ pub fn write(fd: RawFd, buf: &[u8]) -> Result<usize> {
814
814
Errno :: result ( res) . map ( |r| r as usize )
815
815
}
816
816
817
- /// Directive that tells [`lseek`] and [`lseek64`] what the offset is relative to.
818
- /// [`lseek`]: ./fn.lseek.html
819
- /// [`lseek64`]: ./fn.lseek64.html
817
+ /// Directive that tells [`lseek`][1] and [`lseek64`][2] what the offset is relative to.
818
+ ///
819
+ /// [1]: ./fn.lseek.html
820
+ /// [2]: ./fn.lseek64.html
820
821
#[ repr( i32 ) ]
821
822
pub enum Whence {
822
823
/// Specify an offset relative to the start of the file.
@@ -847,7 +848,7 @@ pub enum Whence {
847
848
848
849
/// Move the read/write file offset.
849
850
///
850
- /// See also [lseek(2)(http://pubs.opengroup.org/onlinepubs/9699919799/functions/lseek.html)
851
+ /// See also [lseek(2)] (http://pubs.opengroup.org/onlinepubs/9699919799/functions/lseek.html)
851
852
pub fn lseek ( fd : RawFd , offset : libc:: off_t , whence : Whence ) -> Result < libc:: off_t > {
852
853
let res = unsafe { libc:: lseek ( fd, offset, whence as i32 ) } ;
853
854
@@ -1124,12 +1125,24 @@ pub fn getgroups() -> Result<Vec<Gid>> {
1124
1125
/// specific user and group. For example, given the user `www-data` with UID
1125
1126
/// `33` and the group `backup` with the GID `34`, one could switch the user as
1126
1127
/// follows:
1127
- /// ```
1128
+ ///
1129
+ /// ```rust,no_run
1130
+ /// # use std::error::Error;
1131
+ /// # use nix::unistd::*;
1132
+ /// #
1133
+ /// # fn try_main() -> Result<(), Box<Error>> {
1128
1134
/// let uid = Uid::from_raw(33);
1129
1135
/// let gid = Gid::from_raw(34);
1130
1136
/// setgroups(&[gid])?;
1131
1137
/// setgid(gid)?;
1132
1138
/// setuid(uid)?;
1139
+ /// #
1140
+ /// # Ok(())
1141
+ /// # }
1142
+ /// #
1143
+ /// # fn main() {
1144
+ /// # try_main().unwrap();
1145
+ /// # }
1133
1146
/// ```
1134
1147
#[ cfg( not( any( target_os = "ios" , target_os = "macos" ) ) ) ]
1135
1148
pub fn setgroups ( groups : & [ Gid ] ) -> Result < ( ) > {
@@ -1245,13 +1258,26 @@ pub fn getgrouplist(user: &CStr, group: Gid) -> Result<Vec<Gid>> {
1245
1258
/// UID and GID for the user in the system's password database (usually found
1246
1259
/// in `/etc/passwd`). If the `www-data` user's UID and GID were `33` and `33`,
1247
1260
/// respectively, one could switch the user as follows:
1248
- /// ```
1261
+ ///
1262
+ /// ```rust,no_run
1263
+ /// # use std::error::Error;
1264
+ /// # use std::ffi::CString;
1265
+ /// # use nix::unistd::*;
1266
+ /// #
1267
+ /// # fn try_main() -> Result<(), Box<Error>> {
1249
1268
/// let user = CString::new("www-data").unwrap();
1250
1269
/// let uid = Uid::from_raw(33);
1251
1270
/// let gid = Gid::from_raw(33);
1252
1271
/// initgroups(&user, gid)?;
1253
1272
/// setgid(gid)?;
1254
1273
/// setuid(uid)?;
1274
+ /// #
1275
+ /// # Ok(())
1276
+ /// # }
1277
+ /// #
1278
+ /// # fn main() {
1279
+ /// # try_main().unwrap();
1280
+ /// # }
1255
1281
/// ```
1256
1282
#[ cfg( not( any( target_os = "ios" , target_os = "macos" ) ) ) ]
1257
1283
pub fn initgroups ( user : & CStr , group : Gid ) -> Result < ( ) > {
@@ -1280,7 +1306,7 @@ pub fn pause() -> Result<()> {
1280
1306
1281
1307
/// Suspend execution for an interval of time
1282
1308
///
1283
- /// See also [sleep(2)(http://pubs.opengroup.org/onlinepubs/009695399/functions/sleep.html#tag_03_705_05)
1309
+ /// See also [sleep(2)] (http://pubs.opengroup.org/onlinepubs/009695399/functions/sleep.html#tag_03_705_05)
1284
1310
// Per POSIX, does not fail
1285
1311
#[ inline]
1286
1312
pub fn sleep ( seconds : libc:: c_uint ) -> c_uint {
0 commit comments