예제 #1
0
static void pipe_handler(t_cmds *tmp, t_builtin *b, int fdes[2], int i, int nb)
{
	pid_t	child = -1;

	child = fork();
	if (child == 0)
	{
		dup2(fdes[1], STDOUT_FILENO);
		close(fdes[0]);
		special_char(&tmp->cmd, b);
		init_builtin(b, tmp->cmd);
		clean_quote(b->argv);
		get_command(b->argv[0], b);
		execve(b->path, b->argv, b->env);
		exit(EXIT_FAILURE);
	}
}
예제 #2
0
파일: builtins.c 프로젝트: wtrembla/ft_sh2
void			del_builtin(void)
{
	int			i;
	t_built		*builtin;

	i = 0;
	builtin = init_builtin();
	if (builtin)
	{
		while (i < BUILT_NUM)
		{
			ft_strdel(&(builtin[i].name));
			i++;
		}
		free(builtin);
		builtin = NULL;
	}
}
예제 #3
0
파일: builtins.c 프로젝트: wtrembla/ft_sh2
int				check_builtin(char *command)
{
	char	**av;
	int		i;
	int		ret;
	t_built	*builtin;

	i = 0;
	ret = 0;
	av = ft_strsplit(command, ' ');
	builtin = init_builtin();
	while (i < BUILT_NUM)
	{
		if (!ft_strcmp(av[0], builtin[i].name))
		{
			builtin[i].apply_built(command);
			ret = 1;
		}
		i++;
	}
	del_av(av);
	return (ret);
}
예제 #4
0
tsd_t *ReginaInitializeProcess(void)
{
   int OK;

   if (__regina_tsd_initialized)
      return(&__regina_tsd);
   __regina_tsd_initialized = 1;

                                        /* Set up the current (single) tsd_t:*/
                                        /* Default all values to zero        */
   memset(&__regina_tsd,0,sizeof(__regina_tsd));
   __regina_tsd.MTMalloc = MTMalloc;
   __regina_tsd.MTFree = MTFree;
   __regina_tsd.MTExit = MTExit;

   /* Since the local data structure contains a memory chain for the memory
    * management we initialize it first.
    */
   if ((__regina_tsd.mt_tsd = malloc(sizeof(mt_tsd_t))) == NULL)
      return(NULL);                     /* This is a catastrophy             */
   memset(__regina_tsd.mt_tsd,0,sizeof(mt_tsd_t));

   OK = init_memory(&__regina_tsd);     /* Initialize the memory module FIRST*/

   /* Without the initial memory we don't have ANY chance! */
   if (!OK)
      return(NULL);

   /*
    * Some systems with an own MT file don't compile in MT mode. But they
    * still are systems of that kind.
    */
#if defined(WIN32) || defined(__WIN32__)
   {
      extern OS_Dep_funcs __regina_OS_Win;
      __regina_tsd.OS = &__regina_OS_Win;
   }
#elif defined(OS2) && !defined(DOS)
   {
      extern OS_Dep_funcs __regina_OS_Os2;
      __regina_tsd.OS = &__regina_OS_Os2;
   }
#elif defined(GO32)
   {
      extern OS_Dep_funcs __regina_OS_Other;
      __regina_tsd.OS = &__regina_OS_Other;
   }
#elif defined(unix) || defined(__unix__) || defined(__unix) || defined(__QNX__) || defined(__BEOS__) || defined(SKYOS) || ( defined( __APPLE_CC__ ) && defined( __MACH__ ) )
   {
      extern OS_Dep_funcs __regina_OS_Unx;
      __regina_tsd.OS = &__regina_OS_Unx;
   }
#else
   {
      extern OS_Dep_funcs __regina_OS_Other;
      __regina_tsd.OS = &__regina_OS_Other;
   }
#endif
   __regina_tsd.OS->init();
   OK |= init_vars(&__regina_tsd);      /* Initialize the variable module    */
   OK |= init_stacks(&__regina_tsd);    /* Initialize the stack module       */
   OK |= init_filetable(&__regina_tsd); /* Initialize the files module       */
   OK |= init_math(&__regina_tsd);      /* Initialize the math module        */
   OK |= init_spec_vars(&__regina_tsd); /* Initialize the interprt module    */
   OK |= init_tracing(&__regina_tsd);   /* Initialize the tracing module     */
   OK |= init_builtin(&__regina_tsd);   /* Initialize the builtin module     */
   OK |= init_client(&__regina_tsd);    /* Initialize the client module      */
   OK |= init_library(&__regina_tsd);   /* Initialize the library module     */
   OK |= init_rexxsaa(&__regina_tsd);   /* Initialize the rexxsaa module     */
   OK |= init_shell(&__regina_tsd);     /* Initialize the shell module       */
   OK |= init_envir(&__regina_tsd);     /* Initialize the envir module       */
   OK |= init_expr(&__regina_tsd);      /* Initialize the expr module        */
   OK |= init_error(&__regina_tsd);     /* Initialize the error module       */
#ifdef VMS
   OK |= init_vms(&__regina_tsd);       /* Initialize the vmscmd module      */
   OK |= init_vmf(&__regina_tsd);       /* Initialize the vmsfuncs module    */
#endif
   OK |= init_arexxf(&__regina_tsd);    /* Initialize the arxfuncs modules */
   __regina_tsd.loopcnt = 1;            /* stupid r2perl-module              */
   __regina_tsd.traceparse = -1;
   __regina_tsd.thread_id = 1;

   if (!OK)
      exiterror( ERR_STORAGE_EXHAUSTED, 0 ) ;

   return(&__regina_tsd);
}