From: <st...@us...> - 2004-03-09 23:38:13
|
Update of /cvsroot/uts/uts/src/cam/camd In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1164 Modified Files: cam.h cam_task.c main.c runchild.c runchild.h Log Message: Made camd read camfits command line from $UTS_DIR/etc/camd.conf Index: cam.h =================================================================== RCS file: /cvsroot/uts/uts/src/cam/camd/cam.h,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** cam.h 29 Jan 2004 03:02:34 -0000 1.1.1.1 --- cam.h 9 Mar 2004 23:12:47 -0000 1.2 *************** *** 62,65 **** --- 62,66 ---- inst_ginfo *ginfo; char *childfname; + char *child_cmdline; int chpid; char *device; Index: cam_task.c =================================================================== RCS file: /cvsroot/uts/uts/src/cam/camd/cam_task.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** cam_task.c 29 Jan 2004 03:02:36 -0000 1.1.1.1 --- cam_task.c 9 Mar 2004 23:12:47 -0000 1.2 *************** *** 35,42 **** --- 35,44 ---- { int chpid; + char cmdline[256]; cam->imaging = TRUE; setstatus(cam->ginfo->sec, CAM_INSTNAME, finststatus[IST_BUSY]); + /* old stuff printf("-> Exec task: Spawning child process.\n"); if (chargs == NULL) chargs = alloc_chargs(8); *************** *** 52,58 **** printf("-> Taking %d %1.2f sec. exposure images...\n", cam->task->nexp, cam->task->exptime); /* fork processess */ ! chpid = spawn_child(cam->childfname, chargs); cam->start = FALSE; --- 54,67 ---- printf("-> Taking %d %1.2f sec. exposure images...\n", cam->task->nexp, cam->task->exptime); + */ + + + /* build command line */ + snprintf(cmdline, 255, cam->child_cmdline, + cam->task->exptime, cam->task->nexp, + cam->task->bfname, index); /* fork processess */ ! chpid = spawn_child(cmdline); cam->start = FALSE; Index: main.c =================================================================== RCS file: /cvsroot/uts/uts/src/cam/camd/main.c,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** main.c 5 Mar 2004 19:24:27 -0000 1.2 --- main.c 9 Mar 2004 23:12:47 -0000 1.3 *************** *** 34,44 **** { cam_info *cam; printf("\nCCD daemon ver. 0.3sec - secretary version.\n\n"); ! /* useless, just to get rid of Efence message */ ! free(malloc(1)); ! printf("Jumping into background...n"); goto_bg(); --- 34,53 ---- { cam_info *cam; + char *uts_dir; + char tmpbuf[256]; + FILE *conffile; printf("\nCCD daemon ver. 0.3sec - secretary version.\n\n"); ! uts_dir = getenv("UTS_DIR"); ! snprintf(tmpbuf, 255, "%s/etc/camd.conf", uts_dir); ! conffile = fopen(tmpbuf, "r"); ! if (conffile == NULL) { ! printf("Config file not found.\n"); ! exit(1); ! } ! fgets(tmpbuf, 255, conffile); ! printf("Jumping into background...\n"); goto_bg(); *************** *** 47,50 **** --- 56,61 ---- cam = init_cam(fcamstat); if (cam == NULL) exit(-1); + cam->child_cmdline = calloc(strlen(tmpbuf)+1, sizeof(char)); + strcpy(cam->child_cmdline, tmpbuf); cam_loop(cam); Index: runchild.c =================================================================== RCS file: /cvsroot/uts/uts/src/cam/camd/runchild.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** runchild.c 29 Jan 2004 03:02:36 -0000 1.1.1.1 --- runchild.c 9 Mar 2004 23:12:47 -0000 1.2 *************** *** 34,38 **** } ! int spawn_child(char *childfname, char **args) { int chpid, res; --- 34,38 ---- } ! int spawn_child(char *child_cmdline) { int chpid, res; *************** *** 42,50 **** if (chpid == 0) { /* I am the child, load the code */ ! res = execvp(childfname, args); ! /* this code should never be reached */ ! fprintf(stderr, "Error spawning child process: %s.\n", ! childfname); exit(EOF); /* this ends the child process, not the daemon */ } --- 42,49 ---- if (chpid == 0) { /* I am the child, load the code */ ! printf("%s\n", child_cmdline); ! res = system(child_cmdline); ! fprintf(stderr, "Child process ended with status: %d\n", res); exit(EOF); /* this ends the child process, not the daemon */ } Index: runchild.h =================================================================== RCS file: /cvsroot/uts/uts/src/cam/camd/runchild.h,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** runchild.h 29 Jan 2004 03:02:36 -0000 1.1.1.1 --- runchild.h 9 Mar 2004 23:12:47 -0000 1.2 *************** *** 23,28 **** char **alloc_chargs(int nargs); ! int spawn_child(char *childfname, char **args); ! #endif /* RUNCHILD_H */ \ No newline at end of file --- 23,28 ---- char **alloc_chargs(int nargs); ! int spawn_child(char *child_cmdline); ! #endif /* RUNCHILD_H */ |