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
e8a2fbcd
Unverified
Commit
e8a2fbcd
authored
2 years ago
by
Michael Snoyman
Committed by
GitHub
2 years ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #285 from haskell/wip/T284
Address #284 and #283
parents
c956562f
c25afa93
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
cbits/posix/fork_exec.c
+22
-28
22 additions, 28 deletions
cbits/posix/fork_exec.c
with
22 additions
and
28 deletions
cbits/posix/fork_exec.c
+
22
−
28
View file @
e8a2fbcd
...
@@ -107,23 +107,17 @@ setup_std_handle_fork(int fd,
...
@@ -107,23 +107,17 @@ setup_std_handle_fork(int fd,
* errors. See #266.
* errors. See #266.
*/
*/
int
unshadow_pipe_fd
(
int
fd
,
char
**
failed_doing
)
{
int
unshadow_pipe_fd
(
int
fd
,
char
**
failed_doing
)
{
int
i
=
0
;
if
(
fd
>
2
)
{
int
fds
[
3
]
=
{
0
};
return
fd
;
for
(
i
=
0
;
fd
<
3
&&
i
<
3
;
++
i
)
{
}
fds
[
i
]
=
fd
;
fd
=
dup
(
fd
);
int
new_fd
=
fcntl
(
fd
,
F_DUPFD
,
3
);
if
(
fd
==
-
1
)
{
if
(
new_fd
==
-
1
)
{
*
failed_doing
=
"dup(unshadow)"
;
*
failed_doing
=
"fcntl(F_DUP_FD)"
;
return
-
1
;
return
-
1
;
}
}
}
close
(
fd
);
for
(
int
j
=
0
;
j
<
i
;
++
j
)
{
return
new_fd
;
if
(
close
(
fds
[
j
])
==
-
1
)
{
*
failed_doing
=
"close(unshadow)"
;
return
-
1
;
}
}
return
fd
;
}
}
/* Try spawning with fork. */
/* Try spawning with fork. */
...
@@ -154,17 +148,6 @@ do_spawn_fork (char *const args[],
...
@@ -154,17 +148,6 @@ do_spawn_fork (char *const args[],
return
-
1
;
return
-
1
;
}
}
// Block signals with Haskell handlers. The danger here is that
// with the threaded RTS, a signal arrives in the child process,
// the RTS writes the signal information into the pipe (which is
// shared between parent and child), and the parent behaves as if
// the signal had been raised.
blockUserSignals
();
// See #4074. Sometimes fork() gets interrupted by the timer
// signal and keeps restarting indefinitely.
stopTimer
();
// N.B. execvpe is not supposed on some platforms. In this case
// N.B. execvpe is not supposed on some platforms. In this case
// we emulate this using fork and exec. However, to safely do so
// we emulate this using fork and exec. However, to safely do so
// we need to perform all allocations *prior* to forking. Consequently, we
// we need to perform all allocations *prior* to forking. Consequently, we
...
@@ -181,6 +164,17 @@ do_spawn_fork (char *const args[],
...
@@ -181,6 +164,17 @@ do_spawn_fork (char *const args[],
}
}
#endif
#endif
// Block signals with Haskell handlers. The danger here is that
// with the threaded RTS, a signal arrives in the child process,
// the RTS writes the signal information into the pipe (which is
// shared between parent and child), and the parent behaves as if
// the signal had been raised.
blockUserSignals
();
// See #4074. Sometimes fork() gets interrupted by the timer
// signal and keeps restarting indefinitely.
stopTimer
();
int
pid
=
fork
();
int
pid
=
fork
();
switch
(
pid
)
switch
(
pid
)
{
{
...
...
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