Skip to content

Commit 1aa9d05

Browse files
committed
refactor: CStr literal syntax is not supported
1 parent 792fdd1 commit 1aa9d05

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

test/test_spawn.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use nix::errno::Errno;
33
use nix::spawn::{self, PosixSpawnAttr, PosixSpawnFileActions};
44
use nix::sys::signal;
55
use nix::sys::wait::{waitpid, WaitPidFlag, WaitStatus};
6-
use std::ffi::CString;
6+
use std::ffi::{CStr, CString};
77

88
/// Helper function to find a binary in the $PATH
99
fn which(exe_name: &str) -> Option<std::path::PathBuf> {
@@ -175,7 +175,10 @@ fn spawnp_cmd_does_not_exist() {
175175
let actions = PosixSpawnFileActions::init().unwrap();
176176
let attr = PosixSpawnAttr::init().unwrap();
177177

178-
let bin = c"2b7433c4-523b-470c-abb5-d7ee9fd295d5-fdasf";
178+
let bin = CStr::from_bytes_with_nul(
179+
"2b7433c4-523b-470c-abb5-d7ee9fd295d5-fdasf\0".as_bytes(),
180+
)
181+
.unwrap();
179182
let errno =
180183
spawn::posix_spawnp(bin, &actions, &attr, args, envs).unwrap_err();
181184
assert_eq!(errno, Errno::ENOENT);

0 commit comments

Comments
 (0)