Skip to content

[ash] Add fg command for simple job control to ash#2572

Merged
ghaerr merged 1 commit intomasterfrom
ash
Jan 12, 2026
Merged

[ash] Add fg command for simple job control to ash#2572
ghaerr merged 1 commit intomasterfrom
ash

Conversation

@ghaerr
Copy link
Copy Markdown
Owner

@ghaerr ghaerr commented Jan 12, 2026

Adds fg command to ash for simple job control. Use in conjunction with ^Z (terminal stop) and jobs command to restart stopped jobs into foreground.

ELKS ash doesn't implement full job control. In particular, job control doesn't work well or at all with programs that are stopped while waiting for input, due to problems related to simultaneous reading of stdin by the shell and child programs. This implementation of fg essentially just reads the list of stopped jobs and executes a kill -CONT <pid>. Use jobs to list all stopped or background jobs.

@Mellvik This is the fg command enhancement you requested (the previously described ash enhancements must also be included).

Screenshot showing sample out program (output's X's) being run and stopped twice, then restarted using fg:
Screenshot 2026-01-12 at 4 01 47 PM

@ghaerr ghaerr merged commit f3d069c into master Jan 12, 2026
1 check passed
@ghaerr ghaerr deleted the ash branch January 12, 2026 23:22
@Mellvik
Copy link
Copy Markdown
Contributor

Mellvik commented Jan 13, 2026

Nice, @ghaerr, this is good. an extra treat (!) would be to add '%' syntax to the command, (fg %2). Its may not make sense at this point but let me ask anyway: Is fg w/o parameters supported? Not having '+' and '-' available in the jobs listing, would fg alone simply take the highest job #?

@ghaerr
Copy link
Copy Markdown
Owner Author

ghaerr commented Jan 13, 2026

@Mellvik, all your requested treats have been added in #2574.

fg without parameters will reference the most recently-run or accessed stopped job.

So everything basically now works as expected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants