@@ -187,6 +187,7 @@ impl IntoPyException for &'_ io::Error {
187
187
| Some ( errors:: EALREADY )
188
188
| Some ( errors:: EWOULDBLOCK )
189
189
| Some ( errors:: EINPROGRESS ) => vm. ctx . exceptions . blocking_io_error . clone ( ) ,
190
+ Some ( errors:: ESRCH ) => vm. ctx . exceptions . process_lookup_error . clone ( ) ,
190
191
_ => vm. ctx . exceptions . os_error . clone ( ) ,
191
192
} ,
192
193
} ;
@@ -308,6 +309,9 @@ mod _os {
308
309
O_APPEND , O_CREAT , O_EXCL , O_RDONLY , O_RDWR , O_TRUNC , O_WRONLY , SEEK_CUR , SEEK_END ,
309
310
SEEK_SET ,
310
311
} ;
312
+ #[ cfg( not( target_os = "windows" ) ) ]
313
+ #[ pyattr]
314
+ use libc:: { PRIO_PGRP , PRIO_PROCESS , PRIO_USER } ;
311
315
#[ cfg( any( target_os = "dragonfly" , target_os = "freebsd" , target_os = "linux" ) ) ]
312
316
#[ pyattr]
313
317
use libc:: { SEEK_DATA , SEEK_HOLE } ;
@@ -1358,7 +1362,7 @@ mod posix {
1358
1362
use crate :: builtins:: list:: PyListRef ;
1359
1363
use crate :: pyobject:: PyIterable ;
1360
1364
use bitflags:: bitflags;
1361
- use nix:: errno:: Errno ;
1365
+ use nix:: errno:: { errno , Errno } ;
1362
1366
use nix:: unistd:: { self , Gid , Pid , Uid } ;
1363
1367
use std:: convert:: TryFrom ;
1364
1368
pub ( super ) use std:: os:: unix:: fs:: OpenOptionsExt ;
@@ -2521,6 +2525,42 @@ mod posix {
2521
2525
. collect ( ) ,
2522
2526
) )
2523
2527
}
2528
+
2529
+ cfg_if:: cfg_if! {
2530
+ if #[ cfg( all( target_os = "linux" , target_env = "gnu" ) ) ] {
2531
+ type PriorityWhichType = libc:: __priority_which_t;
2532
+ } else {
2533
+ type PriorityWhichType = libc:: c_int;
2534
+ }
2535
+ }
2536
+
2537
+ #[ cfg( not( target_os = "windows" ) ) ]
2538
+ #[ pyfunction]
2539
+ fn getpriority ( which : PriorityWhichType , who : u32 , vm : & VirtualMachine ) -> PyResult {
2540
+ Errno :: clear ( ) ;
2541
+ let retval = unsafe { libc:: getpriority ( which, who) } ;
2542
+ if errno ( ) != 0 {
2543
+ Err ( errno_err ( vm) )
2544
+ } else {
2545
+ Ok ( vm. ctx . new_int ( retval) )
2546
+ }
2547
+ }
2548
+
2549
+ #[ cfg( not( target_os = "windows" ) ) ]
2550
+ #[ pyfunction]
2551
+ fn setpriority (
2552
+ which : PriorityWhichType ,
2553
+ who : u32 ,
2554
+ priority : i32 ,
2555
+ vm : & VirtualMachine ,
2556
+ ) -> PyResult < ( ) > {
2557
+ let retval = unsafe { libc:: setpriority ( which, who, priority) } ;
2558
+ if retval == -1 {
2559
+ Err ( errno_err ( vm) )
2560
+ } else {
2561
+ Ok ( ( ) )
2562
+ }
2563
+ }
2524
2564
}
2525
2565
#[ cfg( unix) ]
2526
2566
use posix as platform;
0 commit comments