static int redirect_and_run(HFILE local, HFILE remote, int stream, char* command)
{
	int rc = 0;
	HFILE save_pipe = (HFILE)-1;

	set_inherit(local, 0);
	set_inherit(stream, 1);

	do
	{
		rc = DosDupHandle(stream, &save_pipe);

		if(rc)
			break;

		set_inherit(save_pipe, 0);

		HFILE hTmp = stream;

		rc = DosDupHandle(remote, &hTmp);

		if(rc)
			break;

		rc = DosClose(remote);

		if(rc)
			break;

		rc = run(command);

		if(rc)
			break;
	}
	while(0);

	if(save_pipe != -1)
	{
		int rc = 0;
		HFILE hTmp = stream;

		rc = DosDupHandle(save_pipe, &hTmp);
		rc = DosClose(save_pipe);
	}

	return rc;
}
Ejemplo n.º 2
0
//int _papi_hwd_ctl(EventSetInfo_t *zero, int code, _papi_int_option_t *option)
int _papi_hwd_ctl(hwd_context_t *context, int code, _papi_int_option_t *option)
{
  switch (code)
    {
    case PAPI_SET_DEFDOM:
//      return(set_default_domain(zero, option->domain.domain));
    case PAPI_SET_DOMAIN:
      return(set_domain(&option->domain.ESI->machdep, option->domain.domain));
    case PAPI_SET_DEFGRN:
//      return(set_default_granularity(zero, option->granularity.granularity));
    case PAPI_SET_GRANUL:
      return(set_granularity(&option->granularity.ESI->machdep, option->granularity.granularity));
#if 0
    case PAPI_SET_INHERIT:
      return(set_inherit(option->inherit.inherit));
#endif
    default:
      return(PAPI_EINVAL);
    }
}
Ejemplo n.º 3
0
/* This function sets various options in the substrate
 * The valid codes being passed in are PAPI_SET_DEFDOM,
 * PAPI_SET_DOMAIN, PAPI_SETDEFGRN, PAPI_SET_GRANUL
 * and PAPI_SET_INHERIT
 */
int
_papi_hwd_ctl( EventSetInfo_t * zero, int code, _papi_int_option_t * option )
{
	switch ( code ) {
	case PAPI_SET_DEFDOM:
		return ( set_default_domain( zero, option->domain.domain ) );
	case PAPI_SET_DOMAIN:
		return ( set_domain
				 ( option->domain.ESI->machdep, option->domain.domain ) );
	case PAPI_SET_DEFGRN:
		return ( set_default_granularity
				 ( zero, option->granularity.granularity ) );
	case PAPI_SET_GRANUL:
		return ( set_granularity
				 ( option->granularity.ESI->machdep,
				   option->granularity.g ranularity ) );
	case PAPI_SET_INHERIT:
		return ( set_inherit( option->inherit.inherit ) );
	default:
		return ( PAPI_EINVAL );
	}
}