- unify
pipex_child.candpipex_parent.cinto one function - create a list of different Linux command calls in chain (test cases)
- start working on parsing, the output of the parsing being a simplified procecss structure:
typedef struct s_process
{
char *cmd_with_flags; //I already have functions to split into array
int in_fd;
int out_fd;
int child_pid;
} t_process;
- move
ft_get_executable_data()into the t_process structure creation, with table as an output keept in structure - replace char
*args[4]in structure with args array and name of the file in the right variable if necessary - learn BST and if they would be usefull for keeping my processes
- figure out the structure to keep multiple commands
- How to make parent process fail gracefully when child is exiting with ERROR(?)
./pipex infile1 "blahblah a1" "grep pipex" outfile
./pipex infile1 "ls -la" "grep pipex"
./pipex infile0 "grep a1" "wc -l" outfile
./pipex infile1 "ls -la" "grep pipex" outfile
- figure out how to free memory from a string to resolve my cleak even after my program clean-up function (leak des at the bottom of this file)
- norminette on main program structure
- how to handle the save of the data passed from child to parent - it will have unknown size... and structure depending on the commands called
- check if
inputvariable prints correctly inft_child_process()line 43 - figure out how to trigger excve process in child and then push the output into the pipe
- find the bug overriding the name of the input in void ft_child_process(t_pipex **pipex)
- adapt your functions to the parent process
- how to make execve() function aware of the input data?
ie. handle properly:
./pipex infile "grep a1" ls outfileoutput should be the same as< infile grep a1 - Difficult norm
- Valgrind on proper exit
- Valgrind on Error
- //TODO: check if it still works without the else clause in
pipex.c-> yes it works - //TODO: check if it still works with this out? in
pipex_parent.c-> yest it works
- OOO: create a more comprehensive trim function:
ft_trim("ls -l")resulted in"ls -l"instead of"ls -l" - fix properly and test ft_strjoin in libft so that you can use it
- gnl to test and fix - instead of "My first line read?" it reads "rst line read?r" skipping the first BUFFER size of the input
In my basic pipex, parent process opened a pipe from which it later read. I will follow this read-write direction in bonus/minishell:
- pipe_parent[2] will contain fds from which:
- parent process will read
- child process will write
- pipe_child[2] will contain fds from which:
- child process will read
- parent process will write Pipe_child still needs some rethinking once we figure out the structure to hold our processes in the right execution order.
The close() function shall deallocate the file descriptor indicated by fildes. To deallocate means to make the file descriptor available for return by subsequent calls to open() or other functions that allocate file descriptors. All outstanding record locks owned by the process on the file associated with the file descriptor shall be removed (that is, unlocked). Syntax:
int close(int fildes);
Upon successful completion, 0 shall be returned; otherwise, -1 shall be returned and errno set to indicate the error.
Syntax:
ssize_t read(int fildes, void *buf, size_t nbyte);
This function answers a question: can the user who invoked me read/write/execute this file?
protip: run with flag F_OK checks if the file exists
Function to run the bash script. It doesn't work on my computer with WSL
Clue of the project. Creates a spawned process with it's own copy of memory.
Syntax:
int pipe(int pipefd[2]);
This actually creates two working fds, one for read an second for write. Those fd's can be assigned to any thread in order to communicate between each other.
Simply put deleting the file.
Syntax:
void perror(const char *s);
The perror() function produces a message on standard error describing the last error encountered during a call to a system or library function.
Syntax:
char *strerror(int errnum);
The strerror() function returns:
a pointer
to a string
that describes the error code
passed in the argument errnum,
possibly using the LC_MESSAGES part of the current locale to select the appropriate language.
(For example, if errnum is EINVAL, the returned description will be "Invalid argument".) This string must not be modified by the application, but may be modified by a subsequent call to strerror() or strerror_l(). No other library function, including perror(3), will modify this string.
Already used, this option should establish a connection between a file and a file descriptor. Syntax:
int open(const char *path, int oflag, ...);
Exclusive flags (only one can be specified in function):
O_EXEC- Open for execute only (non-directory files). The result is unspecified if this flag is applied to a directory.O_RDONLY- Open for reading only.O_RDWR- Open for reading and writing. The result is undefined if this flag is applied to a FIFO.O_SEARCH- Open directory for search only. The result is unspecified if this flag is applied to a non-directory file.O_WRONLY- Open for writing only.
Inclusive flags (any combination of the followint may be used):
seriously, type
man 3 openand scroll down Upon successful completion, these functions shall open the file and return a non-negative integer representing the file descriptor. Otherwise, these functions shall return -1 and seterrnoto indicate the error. If -1 is returned, no files shall be created or modified.
➜ pipex git:(main) ✗ ./pipex infile0 "grep a1" "wc -l" outfile
[1] 125402 segmentation fault (core dumped) ./pipex infile0 "grep a1" "wc -l" outfile