main.c 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /* ************************************************************************** */
  2. /* */
  3. /* ::: :::::::: */
  4. /* main.c :+: :+: :+: */
  5. /* +:+ +:+ +:+ */
  6. /* By: phella <phella@student.42.fr> +#+ +:+ +#+ */
  7. /* +#+#+#+#+#+ +#+ */
  8. /* Created: 2022/03/03 18:42:18 by phella #+# #+# */
  9. /* Updated: 2022/03/03 18:42:52 by phella ### ########.fr */
  10. /* */
  11. /* ************************************************************************** */
  12. #include "pipex.h"
  13. int main(int argc, char **argv, char **env)
  14. {
  15. int pid;
  16. int fd[2];
  17. if (argc == 5)
  18. {
  19. if (pipe(fd) == -1)
  20. {
  21. perror("Pipe error");
  22. exit(1);
  23. }
  24. pid = fork();
  25. if (pid == -1)
  26. {
  27. perror("Fork error");
  28. exit(1);
  29. }
  30. if (pid == 0)
  31. ft_child_process(argv, env, fd);
  32. ft_parent_process(argv, env, fd);
  33. close(fd[0]);
  34. close(fd[1]);
  35. }
  36. return (0);
  37. }