| 123456789101112131415161718192021222324252627282930 |
- /* ************************************************************************** */
- /* */
- /* ::: :::::::: */
- /* ft_system.c :+: :+: :+: */
- /* +:+ +:+ +:+ */
- /* By: bchanot <bchanot@student.42.fr> +#+ +:+ +#+ */
- /* +#+#+#+#+#+ +#+ */
- /* Created: 2017/12/20 11:11:15 by bchanot #+# #+# */
- /* Updated: 2018/10/14 03:28:18 by bchanot ### ########.fr */
- /* */
- /* ************************************************************************** */
- #include <libft.h>
- #include <unistd.h>
- #include <sys/wait.h>
- void ft_system(char *src)
- {
- pid_t pid;
- char **tab;
- tab = ft_strsplit(src, ' ');
- pid = fork();
- if (pid < 0)
- ft_putendl("Fail to fork.");
- if (pid == 0)
- execve(tab[0], tab, 0);
- waitpid(pid, 0, 0);
- ft_memdel2((void ***)&tab);
- }
|