diff options
author | Homu <homu@barosl.com> | 2016-03-31 15:41:38 +0900 |
---|---|---|
committer | Homu <homu@barosl.com> | 2016-03-31 15:41:38 +0900 |
commit | 4ca407db6b29a0559ed781841c65c4e85222a0a7 (patch) | |
tree | 30a73e67d370e72d0c8585652551f360f94718f7 /test/sys | |
parent | 3fe0503e56aac78f8433e4aa1d6540d0ef951ee7 (diff) | |
parent | c2f8bb71110b894cf165967a20ee321a5766e7fb (diff) | |
download | nix-4ca407db6b29a0559ed781841c65c4e85222a0a7.zip |
Auto merge of #332 - kamalmarhubi:fork-enum, r=fiveop
unistd: Redesign the enum returned by fork()
This changes the name of the enum returned by `fork()` to `ForkResult`,
and changes the `Parent` variant to be struct-like.
The result can be matched like
use nix::unistd::ForkResult::*;
match fork().unwrap() {
Parent { child } => { ... }
Child => { ... }
}
using the shorthand matching syntax for struct-like enum variants.
This is a breaking change.
Diffstat (limited to 'test/sys')
-rw-r--r-- | test/sys/test_wait.rs | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/test/sys/test_wait.rs b/test/sys/test_wait.rs index 7989889b..c2112bac 100644 --- a/test/sys/test_wait.rs +++ b/test/sys/test_wait.rs @@ -1,5 +1,5 @@ use nix::unistd::*; -use nix::unistd::Fork::*; +use nix::unistd::ForkResult::*; use nix::sys::signal::*; use nix::sys::wait::*; use libc::exit; @@ -8,9 +8,9 @@ use libc::exit; fn test_wait_signal() { match fork() { Ok(Child) => pause().unwrap_or(()), - Ok(Parent(child_pid)) => { - kill(child_pid, SIGKILL).ok().expect("Error: Kill Failed"); - assert_eq!(waitpid(child_pid, None), Ok(WaitStatus::Signaled(child_pid, SIGKILL, false))); + Ok(Parent { child }) => { + kill(child, SIGKILL).ok().expect("Error: Kill Failed"); + assert_eq!(waitpid(child, None), Ok(WaitStatus::Signaled(child, SIGKILL, false))); }, // panic, fork should never fail unless there is a serious problem with the OS Err(_) => panic!("Error: Fork Failed") @@ -21,8 +21,8 @@ fn test_wait_signal() { fn test_wait_exit() { match fork() { Ok(Child) => unsafe { exit(12); }, - Ok(Parent(child_pid)) => { - assert_eq!(waitpid(child_pid, None), Ok(WaitStatus::Exited(child_pid, 12))); + Ok(Parent { child }) => { + assert_eq!(waitpid(child, None), Ok(WaitStatus::Exited(child, 12))); }, // panic, fork should never fail unless there is a serious problem with the OS Err(_) => panic!("Error: Fork Failed") |