@@ -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,52 @@ mod posix {
2521
2525
. collect ( ) ,
2522
2526
) )
2523
2527
}
2528
+
2529
+ #[ cfg( target_env = "gnu" ) ]
2530
+ #[ pyfunction]
2531
+ fn getpriority ( which : u32 , who : u32 , vm : & VirtualMachine ) -> PyResult {
2532
+ Errno :: clear ( ) ;
2533
+ let retval = unsafe { libc:: getpriority ( which, who) } ;
2534
+ if errno ( ) != 0 {
2535
+ Err ( errno_err ( vm) )
2536
+ } else {
2537
+ Ok ( vm. ctx . new_int ( retval) )
2538
+ }
2539
+ }
2540
+
2541
+ #[ cfg( target_env = "gnu" ) ]
2542
+ #[ pyfunction]
2543
+ fn setpriority ( which : u32 , who : u32 , priority : i32 , vm : & VirtualMachine ) -> PyResult < ( ) > {
2544
+ let retval = unsafe { libc:: setpriority ( which, who, priority) } ;
2545
+ if retval == -1 {
2546
+ Err ( errno_err ( vm) )
2547
+ } else {
2548
+ Ok ( ( ) )
2549
+ }
2550
+ }
2551
+
2552
+ #[ cfg( all( not( target_env = "gnu" ) , not( target_os = "windows" ) ) ) ]
2553
+ #[ pyfunction]
2554
+ fn getpriority ( which : i32 , who : u32 , vm : & VirtualMachine ) -> PyResult {
2555
+ Errno :: clear ( ) ;
2556
+ let retval = unsafe { libc:: getpriority ( which, who) } ;
2557
+ if errno ( ) != 0 {
2558
+ Err ( errno_err ( vm) )
2559
+ } else {
2560
+ Ok ( vm. ctx . new_int ( retval) )
2561
+ }
2562
+ }
2563
+
2564
+ #[ cfg( all( not( target_env = "gnu" ) , not( target_os = "windows" ) ) ) ]
2565
+ #[ pyfunction]
2566
+ fn setpriority ( which : i32 , who : u32 , priority : i32 , vm : & VirtualMachine ) -> PyResult < ( ) > {
2567
+ let retval = unsafe { libc:: setpriority ( which, who, priority) } ;
2568
+ if retval == -1 {
2569
+ Err ( errno_err ( vm) )
2570
+ } else {
2571
+ Ok ( ( ) )
2572
+ }
2573
+ }
2524
2574
}
2525
2575
#[ cfg( unix) ]
2526
2576
use posix as platform;
0 commit comments