Changeset 411 for trunk/include


Ignore:
Timestamp:
Aug 28, 2012, 9:00:20 PM (12 years ago)
Author:
katerina
Message:

More fixes for ticket #311 (thread safety of --enable-ptrace) and an option for setting the time difference.

Location:
trunk/include
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/samhain.h

    r405 r411  
    331331  int    looptime;                 /* timing for main loop            */
    332332  /*@null@*//*@out@*/ char   * timezone;
     333
     334#ifdef SCREW_IT_UP
     335  int sigtrap_max_duration;
     336#endif
     337
    333338} sh_struct;
    334339
  • trunk/include/sh_unix.h

    r410 r411  
    364364
    365365void   sh_sigtrap_handler (int signum);
    366 extern volatile int sh_not_traced;
    367366
    368367#ifdef HAVE_GETTIMEOFDAY
     
    377376#endif
    378377#endif
    379 void sh_set_save_tv();
    380 void sh_set_untraced(int val);
    381 int  sh_get_untraced();
    382 #endif
     378#endif
     379
     380struct sh_sigtrap_variables {
     381  int not_traced;
     382#ifdef HAVE_GETTIMEOFDAY
     383  struct timeval save_tv;
     384#endif
     385};
     386
     387struct sh_sigtrap_variables * sh_sigtrap_variables_get();
     388
     389int sh_sigtrap_max_duration_set (const char * str);
    383390
    384391static inline
     
    399406int sh_derr(void)
    400407{
    401   sh_set_untraced(0);
     408  struct sh_sigtrap_variables * sigtrap_variables;
     409  sigtrap_variables = sh_sigtrap_variables_get();
     410  if (sigtrap_variables == NULL) {
     411    /* Perhaps, its better to not die, and to continue using Samhain,
     412       even if this part does not work. */
     413    return (0);
     414  }
     415
     416  sigtrap_variables->not_traced = 0;
    402417
    403418#ifdef HAVE_GETTIMEOFDAY
    404   sh_set_save_tv();
     419  gettimeofday(&sigtrap_variables->save_tv, NULL);
    405420#endif
    406421
     
    409424  raise(SIGTRAP);
    410425 
    411   if (sh_get_untraced() == 0)
     426  if (sigtrap_variables->not_traced == 0)
    412427    _exit(5);
    413428
    414   sh_set_untraced(0);
     429  sigtrap_variables->not_traced = 0;
    415430  return (0);
    416431}
Note: See TracChangeset for help on using the changeset viewer.