c_ffi/
process.rs

1//! Process sub-module
2//!
3//!## Required features:
4
5///Runs command, assuming string contains null character at the end.
6///
7///It is UB to pass string without (use macro `c_lit` to create such string)
8pub unsafe fn system_unchecked(cmd: &str) -> i32 {
9    crate::sys::system(cmd.as_ptr() as *const _)
10
11}
12
13///Creates command with `c_lit` macro and pass it to system call
14#[macro_export]
15macro_rules! system {
16    ($e:expr) => {
17        unsafe {
18            $crate::process::system_unchecked($crate::c_lit!($e))
19        }
20    };
21    ($($e:tt)+) => {
22        unsafe {
23            $crate::process::system_unchecked($crate::c_lit!($($e)+))
24        }
25    };
26}