Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
process
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Analyze
Contributor analytics
CI/CD analytics
Repository analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Ian-Woo Kim
process
Commits
5326f67a
Unverified
Commit
5326f67a
authored
1 year ago
by
Michael Snoyman
Committed by
GitHub
1 year ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #296 from neilmayhew/no-cwd-segfault-mac
Prevent a segfault in createProcess on Mac
parents
10ce06aa
bb16ef07
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
cbits/posix/find_executable.c
+3
-1
3 additions, 1 deletion
cbits/posix/find_executable.c
test/main.hs
+28
-0
28 additions, 0 deletions
test/main.hs
with
31 additions
and
1 deletion
cbits/posix/find_executable.c
+
3
−
1
View file @
5326f67a
...
...
@@ -53,10 +53,12 @@ static bool is_executable(char *working_dir, const char *path) {
* found.
*/
static
char
*
find_in_search_path
(
char
*
working_dir
,
char
*
search_path
,
const
char
*
filename
)
{
int
workdir_len
=
strlen
(
working_dir
);
const
int
filename_len
=
strlen
(
filename
);
char
*
tokbuf
;
char
*
path
=
strtok_r
(
search_path
,
":"
,
&
tokbuf
);
if
(
!
working_dir
)
working_dir
=
"."
;
int
workdir_len
=
strlen
(
working_dir
);
while
(
path
!=
NULL
)
{
// N.B. gcc 6.3.0, used by Debian 9, inexplicably warns that `path`
// may not be initialised with -Wall. Silence this warning. See #210.
...
...
This diff is collapsed.
Click to expand it.
test/main.hs
+
28
−
0
View file @
5326f67a
...
...
@@ -41,6 +41,7 @@ main = do
testInterruptWith
testDoubleWait
testKillDoubleWait
testCreateProcess
putStrLn
">>> Tests passed successfully"
run
::
String
->
IO
()
->
IO
()
...
...
@@ -251,6 +252,33 @@ testKillDoubleWait = unless isWindows $ do
(
"INT"
,
True
)
->
checkFirst
"INT"
False
res
_
->
checkFirst
sig
delegate
res
-- Test that createProcess doesn't segfault on Mac with a cwd of Nothing
testCreateProcess
::
IO
()
testCreateProcess
=
run
"createProcess with cwd = Nothing"
$
do
let
env
=
CreateProcess
{
child_group
=
Nothing
,
child_user
=
Nothing
,
close_fds
=
False
,
cmdspec
=
RawCommand
"env"
[]
,
create_group
=
True
,
create_new_console
=
False
,
cwd
=
Nothing
,
delegate_ctlc
=
False
,
detach_console
=
False
,
env
=
Just
[(
"PATH"
,
"/bin:/usr/bin"
)]
,
new_session
=
False
,
std_err
=
Inherit
,
std_in
=
Inherit
,
std_out
=
Inherit
,
use_process_jobs
=
False
}
(
_
,
_
,
_
,
p
)
<-
createProcess
env
res
<-
try
$
waitForProcess
p
case
res
of
Left
e
->
error
$
"waitForProcess threw: "
++
show
(
e
::
SomeException
)
Right
ExitSuccess
->
return
()
Right
exitCode
->
error
$
"unexpected exit code: "
++
show
exitCode
withCurrentDirectory
::
FilePath
->
IO
a
->
IO
a
withCurrentDirectory
new
inner
=
do
orig
<-
getCurrentDirectory
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment