MiniDevil As beautiful as a shell
heredoc_signals.c File Reference

Heredoc signal handling: SIGINT handler for heredoc input. More...

#include <fcntl.h>
#include "signals.h"
#include "libft.h"
+ Include dependency graph for heredoc_signals.c:

Detailed Description

Heredoc signal handling: SIGINT handler for heredoc input.

Definition in file heredoc_signals.c.

Functions

void heredoc_sigint_handler (int sig)
 SIGINT handler for heredoc. More...
 
void setup_heredoc_signals (void)
 Configure signals for heredoc. More...
 
void restore_stdin (void)
 Restore STDIN after heredoc SIGINT closed it. More...
 

Function Documentation

◆ heredoc_sigint_handler()

void heredoc_sigint_handler ( int  sig)

SIGINT handler for heredoc.

Closes STDIN to force readline/gnl to return NULL, thus breaking the heredoc read loop

Parameters
sigSignal number (SIGINT)
Note
STDIN is later restored via restore_stdin()

Definition at line 26 of file heredoc_signals.c.

References g_signal.

Referenced by setup_heredoc_signals().

+ Here is the caller graph for this function:

◆ setup_heredoc_signals()

void setup_heredoc_signals ( void  )

Configure signals for heredoc.

Definition at line 40 of file heredoc_signals.c.

References heredoc_sigint_handler().

Referenced by handle_heredoc().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ restore_stdin()

void restore_stdin ( void  )

Restore STDIN after heredoc SIGINT closed it.

Reopens /dev/tty and uses dup2 to reassign it to fd 0 (STDIN)

Definition at line 62 of file heredoc_signals.c.

Referenced by handle_heredoc().

+ Here is the caller graph for this function:

Go to the source code of this file.