@@ -942,6 +942,17 @@ fn os_chdir(path: PyStringRef, vm: &VirtualMachine) -> PyResult<()> {
942
942
env:: set_current_dir ( path. as_str ( ) ) . map_err ( |err| convert_io_error ( vm, err) )
943
943
}
944
944
945
+ #[ cfg( unix) ]
946
+ fn os_system ( command : PyStringRef , _vm : & VirtualMachine ) -> PyResult < i32 > {
947
+ use libc:: system;
948
+ use std:: ffi:: CString ;
949
+
950
+ let rstr = command. as_str ( ) ;
951
+ let cstr = CString :: new ( rstr) . unwrap ( ) ;
952
+ let x = unsafe { system ( cstr. as_ptr ( ) ) } ;
953
+ Ok ( x)
954
+ }
955
+
945
956
#[ cfg( unix) ]
946
957
fn os_chmod (
947
958
path : PyStringRef ,
@@ -1292,6 +1303,8 @@ pub fn make_module(vm: &VirtualMachine) -> PyObjectRef {
1292
1303
fn extend_module_platform_specific ( vm : & VirtualMachine , module : PyObjectRef ) -> PyObjectRef {
1293
1304
let ctx = & vm. ctx ;
1294
1305
extend_module ! ( vm, module, {
1306
+ "access" => ctx. new_rustfunc( os_access) ,
1307
+ "chmod" => ctx. new_rustfunc( os_chmod) ,
1295
1308
"getppid" => ctx. new_rustfunc( os_getppid) ,
1296
1309
"getgid" => ctx. new_rustfunc( os_getgid) ,
1297
1310
"getegid" => ctx. new_rustfunc( os_getegid) ,
@@ -1301,16 +1314,8 @@ fn extend_module_platform_specific(vm: &VirtualMachine, module: PyObjectRef) ->
1301
1314
"setgid" => ctx. new_rustfunc( os_setgid) ,
1302
1315
"setpgid" => ctx. new_rustfunc( os_setpgid) ,
1303
1316
"setuid" => ctx. new_rustfunc( os_setuid) ,
1304
- "access" => ctx. new_rustfunc( os_access) ,
1305
- "O_DSYNC" => ctx. new_int( libc:: O_DSYNC ) ,
1306
- "O_NDELAY" => ctx. new_int( libc:: O_NDELAY ) ,
1307
- "O_NOCTTY" => ctx. new_int( libc:: O_NOCTTY ) ,
1308
- "O_CLOEXEC" => ctx. new_int( libc:: O_CLOEXEC ) ,
1309
- "chmod" => ctx. new_rustfunc( os_chmod) ,
1317
+ "system" => ctx. new_rustfunc( os_system) ,
1310
1318
"ttyname" => ctx. new_rustfunc( os_ttyname) ,
1311
- "SEEK_SET" => ctx. new_int( Whence :: SeekSet as i8 ) ,
1312
- "SEEK_CUR" => ctx. new_int( Whence :: SeekCur as i8 ) ,
1313
- "SEEK_END" => ctx. new_int( Whence :: SeekEnd as i8 ) ,
1314
1319
"EX_OK" => ctx. new_int( exitcode:: OK as i8 ) ,
1315
1320
"EX_USAGE" => ctx. new_int( exitcode:: USAGE as i8 ) ,
1316
1321
"EX_DATAERR" => ctx. new_int( exitcode:: DATAERR as i8 ) ,
@@ -1327,6 +1332,13 @@ fn extend_module_platform_specific(vm: &VirtualMachine, module: PyObjectRef) ->
1327
1332
"EX_PROTOCOL" => ctx. new_int( exitcode:: PROTOCOL as i8 ) ,
1328
1333
"EX_NOPERM" => ctx. new_int( exitcode:: NOPERM as i8 ) ,
1329
1334
"EX_CONFIG" => ctx. new_int( exitcode:: CONFIG as i8 ) ,
1335
+ "O_DSYNC" => ctx. new_int( libc:: O_DSYNC ) ,
1336
+ "O_NDELAY" => ctx. new_int( libc:: O_NDELAY ) ,
1337
+ "O_NOCTTY" => ctx. new_int( libc:: O_NOCTTY ) ,
1338
+ "O_CLOEXEC" => ctx. new_int( libc:: O_CLOEXEC ) ,
1339
+ "SEEK_SET" => ctx. new_int( Whence :: SeekSet as i8 ) ,
1340
+ "SEEK_CUR" => ctx. new_int( Whence :: SeekCur as i8 ) ,
1341
+ "SEEK_END" => ctx. new_int( Whence :: SeekEnd as i8 ) ,
1330
1342
} ) ;
1331
1343
1332
1344
#[ cfg( not( target_os = "redox" ) ) ]
0 commit comments