Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
R
relibc
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
redox-os
relibc
Commits
8ac0626b
Verified
Commit
8ac0626b
authored
2 years ago
by
Jacob Lorentzon
Browse files
Options
Downloads
Patches
Plain Diff
Handle sigactions properly in execve and fork.
parent
b930cc98
No related branches found
Branches containing commit
No related tags found
1 merge request
!343
Userspace fexec
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/platform/redox/clone.rs
+17
-0
17 additions, 0 deletions
src/platform/redox/clone.rs
src/platform/redox/redox-exec/src/lib.rs
+8
-0
8 additions, 0 deletions
src/platform/redox/redox-exec/src/lib.rs
with
25 additions
and
0 deletions
src/platform/redox/clone.rs
+
17
−
0
View file @
8ac0626b
...
...
@@ -93,6 +93,15 @@ pub unsafe fn pte_clone_impl(stack: *mut usize) -> Result<usize> {
let
_
=
syscall
::
write
(
*
new_filetable_sel_fd
,
&
usize
::
to_ne_bytes
(
*
cur_filetable_fd
))
?
;
}
// Reuse sigactions (on Linux, CLONE_THREAD requires CLONE_SIGHAND which implies the sigactions
// table is reused).
{
let
cur_sigaction_fd
=
FdGuard
::
new
(
syscall
::
dup
(
*
cur_pid_fd
,
b"sigactions"
)
?
);
let
new_sigaction_sel_fd
=
FdGuard
::
new
(
syscall
::
dup
(
*
new_pid_fd
,
b"current-sigactions"
)
?
);
let
_
=
syscall
::
write
(
*
new_sigaction_sel_fd
,
&
usize
::
to_ne_bytes
(
*
cur_sigaction_fd
))
?
;
}
copy_env_regs
(
*
cur_pid_fd
,
*
new_pid_fd
)
?
;
// Unblock context.
...
...
@@ -131,6 +140,14 @@ fn fork_inner(initial_rsp: *mut usize) -> Result<usize> {
copy_str
(
*
cur_pid_fd
,
*
new_pid_fd
,
"name"
)
?
;
copy_str
(
*
cur_pid_fd
,
*
new_pid_fd
,
"cwd"
)
?
;
{
let
cur_sigaction_fd
=
FdGuard
::
new
(
syscall
::
dup
(
*
cur_pid_fd
,
b"sigactions"
)
?
);
let
new_sigaction_fd
=
FdGuard
::
new
(
syscall
::
dup
(
*
cur_sigaction_fd
,
b"copy"
)
?
);
let
new_sigaction_sel_fd
=
FdGuard
::
new
(
syscall
::
dup
(
*
new_pid_fd
,
b"current-sigactions"
)
?
);
let
_
=
syscall
::
write
(
*
new_sigaction_sel_fd
,
&
usize
::
to_ne_bytes
(
*
new_sigaction_fd
))
?
;
}
// Copy existing files into new file table, but do not reuse the same file table (i.e. new
// parent FDs will not show up for the child).
{
...
...
This diff is collapsed.
Click to expand it.
src/platform/redox/redox-exec/src/lib.rs
+
8
−
0
View file @
8ac0626b
...
...
@@ -166,6 +166,14 @@ where
unsafe
{
deactivate_tcb
(
*
open_via_dup
)
?
;
}
{
let
current_sigaction_fd
=
FdGuard
::
new
(
syscall
::
dup
(
*
open_via_dup
,
b"sigactions"
)
?
);
let
empty_sigaction_fd
=
FdGuard
::
new
(
syscall
::
dup
(
*
current_sigaction_fd
,
b"empty"
)
?
);
let
sigaction_selection_fd
=
FdGuard
::
new
(
syscall
::
dup
(
*
open_via_dup
,
b"current-sigactions"
)
?
);
let
_
=
syscall
::
write
(
*
sigaction_selection_fd
,
&
usize
::
to_ne_bytes
(
*
empty_sigaction_fd
))
?
;
}
// TODO: Restore old name if exec failed?
if
let
Ok
(
name_fd
)
=
syscall
::
dup
(
*
open_via_dup
,
b"name"
)
.map
(
FdGuard
::
new
)
{
let
_
=
syscall
::
write
(
*
name_fd
,
path
);
...
...
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