Changeset 7975


Ignore:
Timestamp:
03/26/19 09:09:03 (3 months ago)
Author:
paulf
Message:

cleaned up heartbeat and temp filename creation/opening issues

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/archiving/archman/archman.c

    r7477 r7975  
    176176 * 
    177177 ******************************************************************/ 
    178 #define PROG_VERSION "0.1.4 2016-05-27" 
     178#define PROG_VERSION "0.1.5 2019-03-26" 
    179179int main (int argc, char *argv[]) 
    180180 
     
    877877    logo.type = config->type_heartbeat; 
    878878    time (&bin_time); 
    879     sprintf (buffer, "%ld %d\n", (long)bin_time, config->pid); 
     879    sprintf (buffer, "%ld %ld\n", (long)bin_time, (long) config->pid); 
    880880    size = (long)strlen (buffer); 
    881881 
     
    11771177#ifndef _WINNT 
    11781178  strcpy(tmp_filename, "tmp.XXXXXXXXX"); 
    1179   if ((fd = mkstemp (tmp_filename)) == -1) 
    1180     logit ("e", "Unable to open temporary file in current dir %s\n", tmp_filename); 
     1179  if ((fd = mkstemp (tmp_filename)) == -1) { 
     1180    logit ("e", "Fatal Error: Unable to open temporary file in current dir %s\n", tmp_filename); 
     1181    exit (-1); 
    11811182    /* convert fd to fp */ 
    1182   else if (  (fp = fdopen(fd, "w")) == NULL) 
    1183     logit ("e", "Unable to write to temporary file using fdopen()\n"); 
     1183  } else if (  (fp = fdopen(fd, "w")) == NULL) { 
     1184    logit ("e", "Fatal Error: Unable to write to temporary file using fdopen()\n"); 
     1185    exit (-1); 
     1186  } 
    11841187#else 
    11851188   /* the windows alternative, the original code using insecure tmpnam() */ 
    11861189          /* build the waveman2disk configuration file */ 
    1187    if ( tmpnam (tmp_filename) == NULL ) 
    1188      logit ("e", "Unable to get a temporary file name\n"); 
    1189    else if ((fp = fopen (tmp_filename, "w")) == NULL ) 
    1190      logit ("e", "Unable to open temporary file %s\n", tmp_filename); 
     1190   if ( tmpnam (tmp_filename) == NULL ) { 
     1191     logit ("e", "Fatal Error: Unable to get a temporary file name\n"); 
     1192     exit (-1); 
     1193   } else if ((fp = fopen (tmp_filename, "w")) == NULL ) { 
     1194     logit ("e", "Fatal Error: Unable to open temporary file %s\n", tmp_filename); 
     1195     exit (-1); 
     1196   } 
    11911197#endif 
    11921198  else 
Note: See TracChangeset for help on using the changeset viewer.