mirror of
https://github.com/Savapitech/42sh.git
synced 2026-03-18 21:50:35 +01:00
Add bg
This commit is contained in:
@@ -56,4 +56,5 @@ int builtins_echo(ef_t *ef, char **args);
|
||||
int builtins_astprint(ef_t *, char **args);
|
||||
int builtins_termname(ef_t *ef, char **);
|
||||
int builtins_fg(ef_t *ef, char **);
|
||||
int builtins_bg(ef_t *ef, char **);
|
||||
#endif /* BUILTIND_H */
|
||||
|
||||
27
src/builtins/bg.c
Normal file
27
src/builtins/bg.c
Normal file
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
** EPITECH PROJECT, 2025
|
||||
** __
|
||||
** File description:
|
||||
** _
|
||||
*/
|
||||
|
||||
|
||||
#include <signal.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/wait.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "common.h"
|
||||
#include "exec.h"
|
||||
|
||||
int builtins_bg(ef_t *ef, char **)
|
||||
{
|
||||
int last_job_index = ef->exec_ctx->jobs.sz - 1;
|
||||
|
||||
if (!ef->exec_ctx->isatty) {
|
||||
fprintf(stderr, "No job control in this shell.\n");
|
||||
return RETURN_FAILURE;
|
||||
}
|
||||
kill(-ef->exec_ctx->jobs.jobs[last_job_index].pgid, SIGCONT);
|
||||
return RETURN_SUCCESS;
|
||||
}
|
||||
Reference in New Issue
Block a user