Skip to content

Commit 2f08be5

Browse files
committed
Add os.nice
1 parent aff0e3c commit 2f08be5

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

vm/src/stdlib/os.rs

+13
Original file line numberDiff line numberDiff line change
@@ -776,6 +776,19 @@ mod _os {
776776
Ok(())
777777
}
778778

779+
#[cfg(unix)]
780+
#[pyfunction]
781+
fn nice(increment: i32, vm: &VirtualMachine) -> PyResult<i32> {
782+
use nix::errno::{errno, Errno};
783+
Errno::clear();
784+
let res = unsafe { libc::nice(increment) };
785+
if res == -1 && errno() != 0 {
786+
Err(errno_err(vm))
787+
} else {
788+
Ok(res)
789+
}
790+
}
791+
779792
#[pyfunction]
780793
fn readlink(path: PyPathLike, dir_fd: DirFd<0>, vm: &VirtualMachine) -> PyResult {
781794
let mode = path.mode;

0 commit comments

Comments
 (0)