1
1
use crate :: fmt;
2
- use crate :: io:: { self , Error , ErrorKind } ;
2
+ use crate :: io:: { self , Error } ;
3
3
use crate :: mem;
4
4
use crate :: num:: NonZero ;
5
5
use crate :: sys;
@@ -64,12 +64,7 @@ impl Command {
64
64
65
65
let envp = self . capture_env ( ) ;
66
66
67
- if self . saw_nul ( ) {
68
- return Err ( io:: const_io_error!(
69
- ErrorKind :: InvalidInput ,
70
- "nul byte found in provided data" ,
71
- ) ) ;
72
- }
67
+ self . validate_input ( ) ?;
73
68
74
69
let ( ours, theirs) = self . setup_io ( default, needs_stdin) ?;
75
70
@@ -180,7 +175,7 @@ impl Command {
180
175
// way to avoid that all-together.
181
176
#[ cfg( any( target_os = "tvos" , target_os = "watchos" ) ) ]
182
177
const ERR_APPLE_TV_WATCH_NO_FORK_EXEC : Error = io:: const_io_error!(
183
- ErrorKind :: Unsupported ,
178
+ io :: ErrorKind :: Unsupported ,
184
179
"`fork`+`exec`-based process spawning is not supported on this target" ,
185
180
) ;
186
181
@@ -221,7 +216,7 @@ impl Command {
221
216
thread:: sleep ( delay) ;
222
217
} else {
223
218
return Err ( io:: const_io_error!(
224
- ErrorKind :: WouldBlock ,
219
+ io :: ErrorKind :: WouldBlock ,
225
220
"forking returned EBADF too often" ,
226
221
) ) ;
227
222
}
@@ -236,8 +231,8 @@ impl Command {
236
231
pub fn exec ( & mut self , default : Stdio ) -> io:: Error {
237
232
let envp = self . capture_env ( ) ;
238
233
239
- if self . saw_nul ( ) {
240
- return io :: const_io_error! ( ErrorKind :: InvalidInput , "nul byte found in provided data" , ) ;
234
+ if let Err ( err ) = self . validate_input ( ) {
235
+ return err ;
241
236
}
242
237
243
238
match self . setup_io ( default, true ) {
@@ -497,7 +492,7 @@ impl Command {
497
492
thread:: sleep ( delay) ;
498
493
} else {
499
494
return Err ( io:: const_io_error!(
500
- ErrorKind :: WouldBlock ,
495
+ io :: ErrorKind :: WouldBlock ,
501
496
"posix_spawnp returned EBADF too often" ,
502
497
) ) ;
503
498
}
@@ -1084,7 +1079,6 @@ mod linux_child_ext {
1084
1079
use crate :: mem;
1085
1080
use crate :: os:: linux:: process as os;
1086
1081
use crate :: sys:: pal:: unix:: linux:: pidfd as imp;
1087
- use crate :: sys:: pal:: unix:: ErrorKind ;
1088
1082
use crate :: sys_common:: FromInner ;
1089
1083
1090
1084
#[ unstable( feature = "linux_pidfd" , issue = "82971" ) ]
@@ -1095,7 +1089,9 @@ mod linux_child_ext {
1095
1089
. as_ref ( )
1096
1090
// SAFETY: The os type is a transparent wrapper, therefore we can transmute references
1097
1091
. map ( |fd| unsafe { mem:: transmute :: < & imp:: PidFd , & os:: PidFd > ( fd) } )
1098
- . ok_or_else ( || io:: Error :: new ( ErrorKind :: Uncategorized , "No pidfd was created." ) )
1092
+ . ok_or_else ( || {
1093
+ io:: Error :: new ( io:: ErrorKind :: Uncategorized , "No pidfd was created." )
1094
+ } )
1099
1095
}
1100
1096
1101
1097
fn into_pidfd ( mut self ) -> Result < os:: PidFd , Self > {
0 commit comments