Hola a todos

   Para aquellos a los que interese ya he encontrado la forma. El proceso
es muy simple:

     - Se llama a una rutina escrita en C (mas abajo la incluyo).
     - Esta rutina se encarga de hacer el TimeOut, llamar al programa
final y devolver el control al programa llamador.

   Gracias a todos los que me habeis aportado ideas.

   Un saludo

   Fernando Martinez


#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <signal.h>
#include <unistd.h>
#include <errno.h>

#pragma map(cl_programa, "Programa_a_llamar")
#pragma linkage(cl_programa, OS, nowiden)
void cl_programa(char[], char[]);

/*************  DEFINICION DE CONSTANTES  ***********/
#ifndef TRUE
   #define  TRUE   1
#endif

#ifndef FALSE
   #define  FALSE   0
#endif

#define BLANCO ' '
#define NULO   '\0'
#define BUFFERLENGTH 3126
#define PGMLENGTH 10

 /************** Prototipos de funciones **************/

void EscribeError( char * );
void TimeOutFunc( int );

/**********************************************************/
/* Funcion: EscribeError                                  */
/* Descripci�n: Funcion de logging de errores             */
/*                                                        */
/* Parametros: char * . la cadena de error                */
/*                                                        */
/**********************************************************/

void EscribeError( char *cCadenaError )
{
   time_t ltime;
   char s[150];

   time( &ltime );

   sprintf( s, "Error: %s: %s", cCadenaError, ctime(&ltime));
   printf( "\n%s", s);
}

/**********************************************************/
/* Funcion: EscribeError                                  */
/* Descripci�n: Funcion de error en TimeOUT               */
/*                                                        */
/* Parametros: int NADA. el TimeOut                       */
/*                                                        */
/**********************************************************/

void TimeOutFunc( int NADA )
{
  EscribeError("Error de Time Out, en el Servidor");
  /** Terminamos el proceso a la fuerza **/
  return(1);
}

/**********************************************************/
/* Funcion: Programa Principal                            */
/* Descripci�n: Programa Principal                        */
/**********************************************************/

int main( int argc, char *argv[] )
{
   int  nTimeOut, len;
   char buffer[BUFFERLENGTH + 1], cl_call[10+1];
   char cl_buffer[BUFFERLENGTH + 1 ];

   /** Obtenemos el TimeOut pasado como parametro **/
   nTimeOut = atoi( argv[1] );

   /** Obtenemos el Buffer pasado como parametro **/
   memset( buffer, NULO, sizeof( buffer ) );
   memset( cl_call, NULO, sizeof( cl_call ) );
   strcpy(cl_call, argv[2]);
   strcpy(buffer, argv[3]);

   /** Activamos el TimeOut, si se nos ha pasado > 0 **/
   if( nTimeOut > 0 )
   {
       signal( SIGALRM, TimeOutFunc );
       alarm( nTimeOut );
   }

   /* --------------------------------------- */
   /* LLAMADA AL PROCESO EN CUESTION          */
   /* --------------------------------------- */

   /** Llamada al Proceso en si **/
   cl_programa(cl_call, buffer);

   /** Quitamos el TimeOut **/
   /** signal( SIGALRM, SIG_IGN ); **/
    if( nTimeOut > 0 )
       alarm( 0 );

}



_____________________________________________________
Forum.HELP400 es un servicio m�s de NEWS/400.
� Publicaciones Help400, S.L. - Todos los derechos reservados
http://www.help400.es
_____________________________________________________

Para darte de baja, env�a el mensaje resultante de pulsar
mailto:[EMAIL PROTECTED]

Responder a