|
1 | 1 | // Common functions that are unfortunately missing on illumos and
|
2 | 2 | // Solaris, but often needed by other crates.
|
3 | 3 | use core::cmp::min;
|
4 |
| -#[cfg(target_os = "illumos")] |
5 |
| -use core::cmp::{Ord, Ordering}; |
6 | 4 |
|
7 | 5 | use crate::unix::solarish::*;
|
8 | 6 | use crate::{c_char, c_int, size_t};
|
@@ -90,18 +88,16 @@ pub unsafe fn openpty(
|
90 | 88 |
|
91 | 89 | // Check if the STREAMS modules are already pushed:
|
92 | 90 | let setup = crate::ioctl(fds, I_FIND, LDTERM.as_ptr());
|
93 |
| - match setup.cmp(&0) { |
94 |
| - Ordering::Less => return bail(fdm, fds), |
95 |
| - Ordering::Equal => { |
96 |
| - // The line discipline is not present, so push the appropriate STREAMS |
97 |
| - // modules for the subordinate device: |
98 |
| - if crate::ioctl(fds, I_PUSH, PTEM.as_ptr()) < 0 |
99 |
| - || crate::ioctl(fds, I_PUSH, LDTERM.as_ptr()) < 0 |
100 |
| - { |
101 |
| - return bail(fdm, fds); |
102 |
| - } |
| 91 | + if setup < 0 { |
| 92 | + return bail(fdm, fds); |
| 93 | + } else if setup == 0 { |
| 94 | + // The line discipline is not present, so push the appropriate STREAMS |
| 95 | + // modules for the subordinate device: |
| 96 | + if crate::ioctl(fds, I_PUSH, PTEM.as_ptr()) < 0 |
| 97 | + || crate::ioctl(fds, I_PUSH, LDTERM.as_ptr()) < 0 |
| 98 | + { |
| 99 | + return bail(fdm, fds); |
103 | 100 | }
|
104 |
| - Ordering::Greater => {} |
105 | 101 | }
|
106 | 102 |
|
107 | 103 | // If provided, set the terminal parameters:
|
@@ -142,17 +138,13 @@ pub unsafe fn forkpty(
|
142 | 138 | }
|
143 | 139 |
|
144 | 140 | let pid = crate::fork();
|
145 |
| - match pid.cmp(&0) { |
146 |
| - Ordering::Less => { |
147 |
| - return bail(*amain, fds); |
148 |
| - } |
149 |
| - Ordering::Greater => { |
150 |
| - // In the parent process, we close the subordinate device and return the |
151 |
| - // process ID of the new child: |
152 |
| - crate::close(fds); |
153 |
| - return pid; |
154 |
| - } |
155 |
| - Ordering::Equal => {} |
| 141 | + if pid < 0 { |
| 142 | + return bail(*amain, fds); |
| 143 | + } else if pid > 0 { |
| 144 | + // In the parent process, we close the subordinate device and return the |
| 145 | + // process ID of the new child: |
| 146 | + crate::close(fds); |
| 147 | + return pid; |
156 | 148 | }
|
157 | 149 |
|
158 | 150 | // The rest of this function executes in the child process.
|
|
0 commit comments