Skip to content

Commit d7bacf0

Browse files
authored
Merge pull request #2935 from zetwhite/master
os: implement os.nice
2 parents 67b3388 + c57b8fb commit d7bacf0

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

vm/src/stdlib/os.rs

+12
Original file line numberDiff line numberDiff line change
@@ -2355,6 +2355,18 @@ mod posix {
23552355
)
23562356
}
23572357

2358+
#[pyfunction]
2359+
fn nice(increment: i32, vm: &VirtualMachine) -> PyResult<i32> {
2360+
use nix::errno::{errno, Errno};
2361+
Errno::clear();
2362+
let res = unsafe { libc::nice(increment) };
2363+
if res == -1 && errno() != 0 {
2364+
Err(errno_err(vm))
2365+
} else {
2366+
Ok(res)
2367+
}
2368+
}
2369+
23582370
#[pyfunction]
23592371
fn get_inheritable(fd: RawFd, vm: &VirtualMachine) -> PyResult<bool> {
23602372
use nix::fcntl::fcntl;

0 commit comments

Comments
 (0)