@@ -815,6 +815,7 @@ pub fn write(fd: RawFd, buf: &[u8]) -> Result<usize> {
815
815
}
816
816
817
817
/// Directive that tells [`lseek`] and [`lseek64`] what the offset is relative to.
818
+ ///
818
819
/// [`lseek`]: ./fn.lseek.html
819
820
/// [`lseek64`]: ./fn.lseek64.html
820
821
#[ repr( i32 ) ]
@@ -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
@@ -1143,12 +1144,24 @@ pub fn getgroups() -> Result<Vec<Gid>> {
1143
1144
/// specific user and group. For example, given the user `www-data` with UID
1144
1145
/// `33` and the group `backup` with the GID `34`, one could switch the user as
1145
1146
/// follows:
1146
- /// ```
1147
+ ///
1148
+ /// ```rust,no_run
1149
+ /// # use std::error::Error;
1150
+ /// # use nix::unistd::*;
1151
+ /// #
1152
+ /// # fn try_main() -> Result<(), Box<Error>> {
1147
1153
/// let uid = Uid::from_raw(33);
1148
1154
/// let gid = Gid::from_raw(34);
1149
1155
/// setgroups(&[gid])?;
1150
1156
/// setgid(gid)?;
1151
1157
/// setuid(uid)?;
1158
+ /// #
1159
+ /// # Ok(())
1160
+ /// # }
1161
+ /// #
1162
+ /// # fn main() {
1163
+ /// # try_main().unwrap();
1164
+ /// # }
1152
1165
/// ```
1153
1166
#[ cfg( not( any( target_os = "ios" , target_os = "macos" ) ) ) ]
1154
1167
pub fn setgroups ( groups : & [ Gid ] ) -> Result < ( ) > {
@@ -1264,13 +1277,26 @@ pub fn getgrouplist(user: &CStr, group: Gid) -> Result<Vec<Gid>> {
1264
1277
/// UID and GID for the user in the system's password database (usually found
1265
1278
/// in `/etc/passwd`). If the `www-data` user's UID and GID were `33` and `33`,
1266
1279
/// respectively, one could switch the user as follows:
1267
- /// ```
1280
+ ///
1281
+ /// ```rust,no_run
1282
+ /// # use std::error::Error;
1283
+ /// # use std::ffi::CString;
1284
+ /// # use nix::unistd::*;
1285
+ /// #
1286
+ /// # fn try_main() -> Result<(), Box<Error>> {
1268
1287
/// let user = CString::new("www-data").unwrap();
1269
1288
/// let uid = Uid::from_raw(33);
1270
1289
/// let gid = Gid::from_raw(33);
1271
1290
/// initgroups(&user, gid)?;
1272
1291
/// setgid(gid)?;
1273
1292
/// setuid(uid)?;
1293
+ /// #
1294
+ /// # Ok(())
1295
+ /// # }
1296
+ /// #
1297
+ /// # fn main() {
1298
+ /// # try_main().unwrap();
1299
+ /// # }
1274
1300
/// ```
1275
1301
#[ cfg( not( any( target_os = "ios" , target_os = "macos" ) ) ) ]
1276
1302
pub fn initgroups ( user : & CStr , group : Gid ) -> Result < ( ) > {
@@ -1299,7 +1325,7 @@ pub fn pause() -> Result<()> {
1299
1325
1300
1326
/// Suspend execution for an interval of time
1301
1327
///
1302
- /// See also [sleep(2)(http://pubs.opengroup.org/onlinepubs/009695399/functions/sleep.html#tag_03_705_05)
1328
+ /// See also [sleep(2)] (http://pubs.opengroup.org/onlinepubs/009695399/functions/sleep.html#tag_03_705_05)
1303
1329
// Per POSIX, does not fail
1304
1330
#[ inline]
1305
1331
pub fn sleep ( seconds : libc:: c_uint ) -> c_uint {
0 commit comments