Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
ion
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor 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
Enzo Cioppettini
ion
Commits
cda76ea2
Commit
cda76ea2
authored
7 years ago
by
Jeremy Soller
Browse files
Options
Downloads
Patches
Plain Diff
Move suspend and resume functions to builtins/job_control.rs, add redox implementation
parent
b1c433e9
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/builtins/job_control.rs
+26
-20
26 additions, 20 deletions
src/builtins/job_control.rs
src/shell/job_control.rs
+0
-12
0 additions, 12 deletions
src/shell/job_control.rs
with
26 additions
and
32 deletions
src/builtins/job_control.rs
+
26
−
20
View file @
cda76ea2
...
...
@@ -18,6 +18,30 @@ pub fn set_foreground(pid: u32) {
// TODO
}
#[cfg(all(unix,
not(target_os
=
"redox"
)))]
/// Suspends a given process by it's process ID.
fn
suspend
(
pid
:
u32
)
{
let
_
=
signal
::
kill
(
-
(
pid
as
pid_t
),
Some
(
NixSignal
::
SIGTSTP
));
}
#[cfg(all(unix,
not(target_os
=
"redox"
)))]
/// Resumes a given process by it's process ID.
fn
resume
(
pid
:
u32
)
{
let
_
=
signal
::
kill
(
-
(
pid
as
pid_t
),
Some
(
NixSignal
::
SIGCONT
));
}
#[cfg(target_os
=
"redox"
)]
fn
suspend
(
pid
:
u32
)
{
use
syscall
;
let
_
=
syscall
::
kill
(
pid
as
usize
,
syscall
::
SIGSTOP
);
}
#[cfg(target_os
=
"redox"
)]
fn
resume
(
pid
:
u32
)
{
use
syscall
;
let
_
=
syscall
::
kill
(
pid
as
usize
,
syscall
::
SIGCONT
);
}
/// Display a list of all jobs running in the background.
pub
fn
jobs
(
shell
:
&
mut
Shell
)
{
let
stderr
=
stderr
();
...
...
@@ -30,7 +54,6 @@ pub fn jobs(shell: &mut Shell) {
}
}
#[cfg(all(unix,
not(target_os
=
"redox"
)))]
pub
fn
fg
(
shell
:
&
mut
Shell
,
args
:
&
[
&
str
])
->
i32
{
let
mut
status
=
0
;
for
arg
in
args
{
...
...
@@ -52,7 +75,7 @@ pub fn fg(shell: &mut Shell, args: &[&str]) -> i32 {
status
=
shell
.watch_foreground
(
njob
)
},
ProcessState
::
Stopped
=>
{
let
_
=
signal
::
kill
(
-
(
job
.pid
as
i32
),
Some
(
Signal
::
SIGCONT
)
);
resume
(
job
.pid
);
set_foreground
(
njob
);
// TODO: This doesn't work
status
=
shell
.watch_foreground
(
njob
);
...
...
@@ -71,15 +94,6 @@ pub fn fg(shell: &mut Shell, args: &[&str]) -> i32 {
status
}
#[cfg(target_os
=
"redox"
)]
pub
fn
fg
(
_
:
&
mut
Shell
,
_
:
&
[
&
str
])
->
i32
{
let
stderr
=
stderr
();
// TODO: Redox signal handling support
let
_
=
writeln!
(
stderr
.lock
(),
"Redox does not yet support signals"
);
0
}
#[cfg(all(unix,
not(target_os
=
"redox"
)))]
pub
fn
bg
(
shell
:
&
mut
Shell
,
args
:
&
[
&
str
])
->
i32
{
let
mut
error
=
false
;
let
stderr
=
stderr
();
...
...
@@ -93,7 +107,7 @@ pub fn bg(shell: &mut Shell, args: &[&str]) -> i32 {
error
=
true
;
},
ProcessState
::
Stopped
=>
{
let
_
=
signal
::
kill
(
-
(
job
.pid
as
i32
),
Some
(
Signal
::
SIGCONT
)
);
resume
(
job
.pid
);
job
.state
=
ProcessState
::
Running
;
let
_
=
writeln!
(
stderr
,
"[{}] {} Running"
,
njob
,
job
.pid
);
},
...
...
@@ -113,11 +127,3 @@ pub fn bg(shell: &mut Shell, args: &[&str]) -> i32 {
}
if
error
{
FAILURE
}
else
{
SUCCESS
}
}
#[cfg(target_os
=
"redox"
)]
pub
fn
bg
(
_
:
&
mut
Shell
,
_
:
&
[
&
str
])
->
i32
{
let
stderr
=
stderr
();
// TODO: Redox signal handling support
let
_
=
writeln!
(
stderr
.lock
(),
"Redox does not yet support signals"
);
0
}
This diff is collapsed.
Click to expand it.
src/shell/job_control.rs
+
0
−
12
View file @
cda76ea2
...
...
@@ -9,7 +9,6 @@ use super::status::*;
use
super
::
Shell
;
pub
trait
JobControl
{
fn
suspend
(
&
mut
self
,
pid
:
u32
);
fn
wait_for_background
(
&
mut
self
);
fn
handle_signal
(
&
self
,
signal
:
i32
);
fn
foreground_send
(
&
self
,
signal
:
i32
);
...
...
@@ -122,17 +121,6 @@ pub struct BackgroundProcess {
}
impl
<
'a
>
JobControl
for
Shell
<
'a
>
{
#[cfg(all(unix,
not(target_os
=
"redox"
)))]
/// Suspends a given process by it's process ID.
fn
suspend
(
&
mut
self
,
pid
:
u32
)
{
let
_
=
signal
::
kill
(
-
(
pid
as
pid_t
),
Some
(
NixSignal
::
SIGTSTP
));
}
#[cfg(target_os
=
"redox"
)]
fn
suspend
(
&
mut
self
,
_
:
u32
)
{
// TODO: Redox doesn't support signals yet.
}
#[cfg(all(unix,
not(target_os
=
"redox"
)))]
/// Waits until all running background tasks have completed, and listens for signals in the
/// event that a signal is sent to kill the running tasks.
...
...
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