Skip to content

Debugger #1

@nikander100

Description

@nikander100

Add Debug includes/macro/defines and functions for open, close, debug prints ie.

  • called from x fucntion.
  • open debug
  • close debug
  • malloc wrapper

example below

hell-2.1.0$> cat | cat | catls
Called function is: setup_pipes 
Closed FD: [6] in: [parent_proces]
Closed FD: [5] in: [child_proces]
Closed FD: [6] in: [child_proces]
Called function is: executer 
Closed FD: [7] in: [parent_proces]
Closed FD: [5] in: [parent_proces]
Closed FD: [6] in: [child_proces]
Closed FD: [7] in: [child_proces]
Closed FD: [5] in: [child_proces]
Called function is: executer 
Closed FD: [7] in: [parent_proces]
Closed FD: [6] in: [parent_proces]
Closed FD: [5] in: [parent_proces]
Closed FD: [5] in: [child_proces]
Closed FD: [6] in: [child_proces]
Called function is: executer 
minishell: command not found: catls
//in main.c (but should eventually go in debug lib
#undef close

void	my_close(int fd, char *func)
{
	close(fd);
	dprintf(4, "Closed FD: [%i] in: [%s]\n", fd, func);
}

//in debug header
#define close(X) my_close( X, __func__)

//in func.c
void	set_redirection_fd(t_mother_struct *ms, int *fork_info)
{
	dprintf(4, "Called function is: %s \n", __func__);
	if (ms->hdoc.in_fd)
	{
		close(fork_info[IN]);
		fork_info[IN] = ms->hdoc.in_fd;
		dup2(fork_info[IN], STDIN_FILENO);
	}
	if (ms->hdoc.out_fd)
	{
		close(fork_info[OUT]);
		fork_info[OUT] = ms->hdoc.out_fd;
		dup2(fork_info[OUT], STDOUT_FILENO);
	}
}

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions