]>
git.proxmox.com Git - rustc.git/blob - library/std/src/sys/unix/process/process_unsupported.rs
3 use crate::io
::ErrorKind
;
4 use crate::num
::NonZeroI32
;
7 use crate::sys
::pipe
::AnonPipe
;
8 use crate::sys
::process
::process_common
::*;
9 use crate::sys
::unix
::unsupported
::*;
10 use core
::ffi
::NonZero_c_int
;
12 use libc
::{c_int, pid_t}
;
14 ////////////////////////////////////////////////////////////////////////////////
16 ////////////////////////////////////////////////////////////////////////////////
23 ) -> io
::Result
<(Process
, StdioPipes
)> {
27 pub fn exec(&mut self, default: Stdio
) -> io
::Error
{
32 ////////////////////////////////////////////////////////////////////////////////
34 ////////////////////////////////////////////////////////////////////////////////
41 pub fn id(&self) -> u32 {
45 pub fn kill(&mut self) -> io
::Result
<()> {
49 pub fn wait(&mut self) -> io
::Result
<ExitStatus
> {
53 pub fn try_wait(&mut self) -> io
::Result
<Option
<ExitStatus
>> {
58 #[derive(PartialEq, Eq, Clone, Copy, Debug)]
59 pub struct ExitStatus(c_int
);
62 pub fn success(&self) -> bool
{
63 self.code() == Some(0)
66 pub fn exit_ok(&self) -> Result
<(), ExitStatusError
> {
67 Err(ExitStatusError(1.try_into().unwrap()))
70 pub fn code(&self) -> Option
<i32> {
74 pub fn signal(&self) -> Option
<i32> {
78 pub fn core_dumped(&self) -> bool
{
82 pub fn stopped_signal(&self) -> Option
<i32> {
86 pub fn continued(&self) -> bool
{
90 pub fn into_raw(&self) -> c_int
{
95 /// Converts a raw `c_int` to a type-safe `ExitStatus` by wrapping it without copying.
96 impl From
<c_int
> for ExitStatus
{
97 fn from(a
: c_int
) -> ExitStatus
{
102 impl fmt
::Display
for ExitStatus
{
103 fn fmt(&self, f
: &mut fmt
::Formatter
<'_
>) -> fmt
::Result
{
104 write
!(f
, "exit code: {}", self.0)
108 #[derive(PartialEq, Eq, Clone, Copy, Debug)]
109 pub struct ExitStatusError(NonZero_c_int
);
111 impl Into
<ExitStatus
> for ExitStatusError
{
112 fn into(self) -> ExitStatus
{
113 ExitStatus(self.0.into
())
117 impl ExitStatusError
{
118 pub fn code(self) -> Option
<NonZeroI32
> {
119 ExitStatus(self.0.into
()).code().map(|st
| st
.try_into().unwrap())