minishell
Minishell Project for École 42
Loading...
Searching...
No Matches
exit_builtin.c File Reference

Builtin function for the exit command. More...

#include "minishell.h"
Include dependency graph for exit_builtin.c:

Functions

bool is_arg_number (char *arg)
 Checks if a string represents a valid numeric argument.
 
int exit_builtin (t_shell *shell, char **args, bool in_child)
 Handles the exit command when executed in a child process.
 

Detailed Description

Builtin function for the exit command.

This file contains the implementation of the exit builtin command The exit command is used to terminate the shell and optionally specify an exit status.

Function Documentation

◆ exit_builtin()

int exit_builtin ( t_shell shell,
char **  args,
bool  in_child 
)

Handles the exit command when executed in a child process.

This function is called when the exit command is executed within a child process. It handles the termination of the child process based on the provided arguments.

Parameters
[in]shellA pointer to the shell struct.
[in]argsAn array of strings containing the arguments.
[in]in_childA boolean indicating whether the function is called in a child process.
Returns
The exit status of the child process.

◆ is_arg_number()

bool is_arg_number ( char *  arg)

Checks if a string represents a valid numeric argument.

This function is used to determine if a string can be interpreted as a valid numeric argument for the exit command. It checks whether all characters in the string are digits. Skips the first '-' or '+'.

Parameters
[in]argThe string to be checked.
Returns
true if the string is a valid numeric argument, false otherwise.