mirror of
https://github.com/Savapitech/42sh.git
synced 2026-01-18 16:57:28 +01:00
28 lines
542 B
C
28 lines
542 B
C
/*
|
|
** EPITECH PROJECT, 2025
|
|
** __
|
|
** File description:
|
|
** _
|
|
*/
|
|
|
|
#include <stdlib.h>
|
|
#include <unistd.h>
|
|
|
|
#include "common.h"
|
|
#include "env.h"
|
|
#include "exec.h"
|
|
|
|
int builtins_exit(ef_t *ef, char **args[[gnu::unused]])
|
|
{
|
|
if (ef->flags & F_PIPE &&
|
|
!(ef->out_fd == STDOUT_FILENO || ef->p_i == ef->p_sz - 1))
|
|
return RETURN_SUCCESS;
|
|
if (!(ef->flags & F_EXIT)) {
|
|
ef->flags |= F_EXIT;
|
|
return RETURN_SUCCESS;
|
|
}
|
|
free_env(ef->env);
|
|
free(ef->buffer);
|
|
exit(ef->exec_ctx->history->last_exit_code);
|
|
}
|