Hello,
I have written a daemon program that will take a file created by another
process, execute this file (it is a shell script), and create a return file
so that the original process knows whether or not the file was processed
successfully. My problem is that after the daemon program is running for
about 10 to 20 seconds, I am receiving the following error:
crt0: ERROR couldn't open /usr/lib/dld.sl errno:000000024
I am running the program on an HP-UX B.10.20 A 9000/750 machine.
Here is the program:
/* Library Includes */
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <time.h>
#include <crypt.h>
#include <fcntl.h>
#include <errno.h>
#include "nlkdmon.h"
/* Symbolic Constants */
#define TRUE 1
#define FILE_MODE ( S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH )
#define MAXLINE 4096
#define write_lock(fd, offset, whence, len) \
lock_reg(fd, F_SETLK, F_WRLCK, offset, whence, len)
/* Function prototypes */
void check_daemon_running(void);
int lock_reg(int fd, int cmd, int type, off_t offset, int whence, off_t
len);
int update_ca_unicenter (char * infilename);
int retrieve_mqm_dir (char * mqmDataDir);
int create_hold_dir(char * mqmDataDir);
/* Global variables */
char pgmname[9];
char pidfile[100];
int main(int argc, char * argv[])
{
FILE *outFilePtr, *filesPtr;
char outfilename[100], filelist[100];
char holdDir[200] = {" "};
int upd_rc, rc;
char infilename[100] = {" "};
struct Outrec OutData, *OutDataPtr;
OutDataPtr = &OutData;
if (argc != 2)
{
fprintf( stderr, "Usage: %s <directory location for files> return code
= 1\n", argv[0] );
return 1;
} /* End if argc not = 2 */
else
{
strcpy (pgmname, argv[0]);
strcpy (pidfile, argv[1]);
strcat (pidfile, "/pidfile");
} /* End else argc = 2 */
check_daemon_running();
rc = retrieve_mqm_dir (mqmDataDir); /* Gets directory location for input
files */
if (rc == 0)
{
strcpy(holdDir, mqmDataDir);
strcat(holdDir, "/hold");
rc = create_hold_dir(holdDir); /* Creates a hold directory for files to
be processed at a later time */
} /* End rc equal 0 */
if (rc != 0)
return 1;
/ * Set up the infinite loop for the daemon to continue running */
while (TRUE)
{
sprintf(filelist, "%s/filelist", mqmDataDir);
sprintf(command, "ls -1 %s/*.*dat 2>/dev/null > %s", mqmDataDir,
filelist);
system(command);
if ((filesPtr = fopen(filelist, "rb")) != NULL)
{
fscanf(filesPtr, "%s", infilename);
while (! feof (filesPtr))
{
strcpy(outfilename, infilename);
strcat(outfilename, "Return");
if ((outFilePtr = fopen(outfilename, "wb")) == NULL)
{
printf("\nOuput file, %s, could not be opened\n", outfilename);
} /* End if outFile not open */
upd_rc = update_ca_unicenter(infilename);
sprintf(OutDataPtr->status,"%i", upd_rc);
fwrite(&OutData, sizeof(struct Outrec), 1, outFilePtr);
fclose(outFilePtr);
if (upd_rc == 0)
{
/* Remove data file so that it is not re-processed */
sprintf(command, "rm %s 2>/dev/null", infilename);
system(command);
} /* End if upd_rc equal 0 */
else
{
sprintf(command, "mv %s %s", infilename, holdDir);
system(command);
} /* End else upd_rc not equal 0 */
fscanf(filesPtr, "%s", infilename);
} /* End while more files to process */
} /* End if filelist open successful */
usleep(500000);
} /* End while true */
return 0;
I have used the examples from the R. Stevens book on creating daemonQuote:} /* End of nlkdmon main */
programs. My compiler is on a different HP so I FTP the object module over
to this machine and run the following make file to create my executable:
ROOTDIR=..
BINDIR=${ROOTDIR}/bin
OBJDIR=${ROOTDIR}/obj
LIBDIR=/usr/lib
LDFLAGS=/usr/ccs/lib/crt0.o -lc
.SUFFIXES: .c.C.o
${BINDIR}/nlkdmon : ${OBJDIR}/nlkdmon.o
I would greatly appreciate any help or guidance that anyone could give to me
for this problem. Also, since this is my first attempt at creating a daemon
program, I would appreciate any suggestions for improvement.
Thank you for your help,
Teresa Miller