Skip to content
builtin_exec.c 566 B
Newer Older
Seblu's avatar
Seblu committed
/*
** builtin_exec.c for 42sh in /goinfre/seblu/42sh/src/builtin
**
** Made by Seblu
** Login   <luttri_s@epita.fr>
**
** Started on  Thu May 11 10:00:36 2006 Seblu
Seblu's avatar
Seblu committed
** Last update Fri Nov 17 13:01:59 2006 seblu
Seblu's avatar
Seblu committed
*/

#include <assert.h>
#include <stdio.h>
Seblu's avatar
Seblu committed
#include <errno.h>
#include <string.h>
Seblu's avatar
Seblu committed
#include <unistd.h>
Seblu's avatar
Seblu committed
#include "../shell/shell.h"
Seblu's avatar
Seblu committed

Seblu's avatar
Seblu committed
int	builtin_exec(char *argv[])
Seblu's avatar
Seblu committed
{
Seblu's avatar
Seblu committed
  assert(argv);
  if (!argv[1])
    return 0;
  if (execvp(argv[1], argv + 1) == -1) {
    fprintf(stderr, "%s: exec: %s.\n", shell->name, strerror(errno));
    return 127;
  }
  return 0;
Seblu's avatar
Seblu committed
}