]>
git.proxmox.com Git - rustc.git/blob - library/std/src/sys/unix/process/process_unsupported.rs
3 use crate::num
::NonZeroI32
;
4 use crate::sys
::process
::process_common
::*;
5 use crate::sys
::unix
::unsupported
::*;
6 use core
::ffi
::NonZero_c_int
;
8 use libc
::{c_int, pid_t}
;
10 ////////////////////////////////////////////////////////////////////////////////
12 ////////////////////////////////////////////////////////////////////////////////
19 ) -> io
::Result
<(Process
, StdioPipes
)> {
23 pub fn exec(&mut self, _default
: Stdio
) -> io
::Error
{
28 ////////////////////////////////////////////////////////////////////////////////
30 ////////////////////////////////////////////////////////////////////////////////
37 pub fn id(&self) -> u32 {
41 pub fn kill(&mut self) -> io
::Result
<()> {
45 pub fn wait(&mut self) -> io
::Result
<ExitStatus
> {
49 pub fn try_wait(&mut self) -> io
::Result
<Option
<ExitStatus
>> {
54 #[derive(PartialEq, Eq, Clone, Copy, Debug)]
55 pub struct ExitStatus(c_int
);
58 #[cfg_attr(target_os = "horizon", allow(unused))]
59 pub fn success(&self) -> bool
{
60 self.code() == Some(0)
63 pub fn exit_ok(&self) -> Result
<(), ExitStatusError
> {
64 Err(ExitStatusError(1.try_into().unwrap()))
67 pub fn code(&self) -> Option
<i32> {
71 pub fn signal(&self) -> Option
<i32> {
75 pub fn core_dumped(&self) -> bool
{
79 pub fn stopped_signal(&self) -> Option
<i32> {
83 pub fn continued(&self) -> bool
{
87 pub fn into_raw(&self) -> c_int
{
92 /// Converts a raw `c_int` to a type-safe `ExitStatus` by wrapping it without copying.
93 impl From
<c_int
> for ExitStatus
{
94 fn from(a
: c_int
) -> ExitStatus
{
99 impl fmt
::Display
for ExitStatus
{
100 fn fmt(&self, f
: &mut fmt
::Formatter
<'_
>) -> fmt
::Result
{
101 write
!(f
, "exit code: {}", self.0)
105 #[derive(PartialEq, Eq, Clone, Copy, Debug)]
106 pub struct ExitStatusError(NonZero_c_int
);
108 impl Into
<ExitStatus
> for ExitStatusError
{
109 fn into(self) -> ExitStatus
{
110 ExitStatus(self.0.into
())
114 impl ExitStatusError
{
115 pub fn code(self) -> Option
<NonZeroI32
> {
116 ExitStatus(self.0.into
()).code().map(|st
| st
.try_into().unwrap())