- Fixed a bug in hklscan: core dump when writing to file
- Fixed two small issues with evcontroller: no test for privilege on drive - Many changes to AMOR software.
This commit is contained in:
42
nserver.c
42
nserver.c
@ -6,13 +6,20 @@
|
||||
|
||||
Mark Koennecke, October 1996
|
||||
Revised for use with tasker: Mark Koennecke, September 1997
|
||||
|
||||
Added code to redirect stdout/sterr to file.
|
||||
|
||||
Mark Koennecke, May 2000
|
||||
|
||||
Copyright: see copyright.h
|
||||
----------------------------------------------------------------------------*/
|
||||
#define NEEDDINTINIT
|
||||
#include "fortify.h"
|
||||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
#include <time.h>
|
||||
#include "conman.h"
|
||||
#include "SCinter.h"
|
||||
@ -75,7 +82,8 @@
|
||||
pNetRead pReader = NULL;
|
||||
pPerfMon pMon = NULL;
|
||||
CommandList *pCom;
|
||||
|
||||
pid_t myPid;
|
||||
|
||||
/* allocate a new server structure */
|
||||
self = (pServer)malloc(sizeof(SicsServer));
|
||||
if(!self)
|
||||
@ -86,6 +94,7 @@
|
||||
memset(self,0,sizeof(SicsServer));
|
||||
*pServ = self;
|
||||
|
||||
|
||||
/* configure fortify */
|
||||
iFortifyScope = Fortify_EnterScope();
|
||||
Fortify_CheckAllMemory();
|
||||
@ -119,7 +128,28 @@
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
check for option RedirectFile and redirect stout/sterr to it
|
||||
if present.
|
||||
*/
|
||||
pPtr = NULL;
|
||||
pPtr = IFindOption(pSICSOptions,"RedirectFile");
|
||||
if(pPtr != NULL)
|
||||
{
|
||||
myPid = getpid();
|
||||
sprintf(pBueffel,"%s%5.5d.log",pPtr,(int)myPid);
|
||||
fp = freopen(pBueffel,"w",stdout);
|
||||
if(!fp)
|
||||
{
|
||||
printf("Failed to redirect stdout/stderr to %s\n",pBueffel);
|
||||
}
|
||||
fp = freopen(pBueffel,"w",stderr);
|
||||
if(!fp)
|
||||
{
|
||||
printf("Failed to redirect stdout/stderr to %s\n",pBueffel);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* initialise net reader */
|
||||
pPtr = NULL;
|
||||
@ -294,6 +324,14 @@
|
||||
{
|
||||
printf("ERROR: Cannot allocate dummy connection, status NOT saved");
|
||||
}
|
||||
|
||||
/* close redirection file if present */
|
||||
pText = NULL;
|
||||
pText = IFindOption(pSICSOptions,"RedirectFile");
|
||||
if(pText)
|
||||
{
|
||||
fclose(stderr);
|
||||
}
|
||||
|
||||
/* clean out */
|
||||
if(pSICSOptions)
|
||||
|
Reference in New Issue
Block a user