Archived
1
0

[✏️] norm: normed project.

This commit is contained in:
2024-04-07 11:04:27 +02:00
parent 81f16dc864
commit 8ec6d84e1b
2 changed files with 2 additions and 48 deletions

View File

@ -6,7 +6,7 @@
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/04/06 14:15:47 by adjoly #+# #+# */
/* Updated: 2024/04/06 14:18:27 by adjoly ### ########.fr */
/* Updated: 2024/04/07 11:04:19 by adjoly ### ########.fr */
/* */
/* ************************************************************************** */
@ -15,7 +15,7 @@
# include <sys/wait.h>
#include "pipex.h"
# include "pipex.h"
void exec_pipe(t_pipex *pipex);

46
test.c
View File

@ -1,46 +0,0 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* test.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/04/03 15:36:42 by adjoly #+# #+# */
/* Updated: 2024/04/04 15:20:24 by adjoly ### ########.fr */
/* */
/* ************************************************************************** */
#include <stdio.h>
#include <unistd.h>
#include <sys/wait.h>
int main()
{
char *cmd[] = {"sleep", "5", 0};
char *path = "/bin/sleep";
char *cmd2[] = {"sleep", "5", 0};
char *path2 = "/bin/sleep";
int fd[2];
if (pipe(fd) == -1)
return(1);
int pid;
pid = fork();
if (!pid)
{
dup2(fd[1], STDOUT_FILENO);
close(fd[0]);
close(fd[1]);
execve(path, cmd, NULL);
}
close(fd[1]);
int pid2 = fork();
if (!pid2)
{
dup2(fd[0], STDIN_FILENO);
close(fd[0]);
execve(path2, cmd2, NULL);
}
close(fd[1]);
waitpid(pid, NULL, 0);
waitpid(pid2, NULL, 0);
}