TutExit


Name

TutExit — call exit handlers and terminate process

Synopsis

void TutExit(status) 
T_INT4 status; 

Arguments

status — exit status of the process

Return Values

None

Diagnostics

None

Description

TutExit calls all exit handlers registered internally by SmartSockets in the reverse order of their registration and then calls the system call exit(). If the process has registered any functions by calling atexit(), these functions are called only after the internal SmartSockets exit handlers functions have been called.

Although TutExit does not return a value, the exiting process returns an exit status to the calling process. The exit status codes T_EXIT_FAILURE and T_EXIT_SUCCESS are defined and may be used to indicate successful or unsuccessful process termination.

Caution

If the process calls the system call exit() instead of TutExit(), the internal SmartSockets exit handlers are not called and the behavior of the process or application is unknown. The correct way to terminate a SmartSockets application or process is to call TutExit().

Examples

This example shows the correct way to exit a SmartSockets process:

#include <rtworks/ipc.h> 
 
void MyExitHandler() 
{ 
  /* do something .... */ 
  TutOut("Exit from My exit Handler\n"); 
} /* MyExitHandler */ 
int main() 
{  
  T_IPC_MT mt; 
  T_IPC_MSG msg; 
  T_BOOL status; 
 
  mt = TipcMtCreate(T_MT_INFO); 
 
 msg = TipcMsgCreate(mt); 
  /* Do something */ 
 
  /*  
   * The process needs to call TutExit() before exiting  
   * in order to get the correct behavior. 
   */ 
 TutExit(T_EXIT_SUCCESS); 
} /* main */ 

TIBCO SmartSockets™ Utilities
Software Release 6.8, July 2006
Copyright © TIBCO Software Inc. All rights reserved
www.tibco.com