From: <st...@us...> - 2004-03-09 23:15:29
|
Update of /cvsroot/uts/uts/src/tel/teld In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28536/src/tel/teld Modified Files: main.c runchild.c runchild.h tel.h tel_task.c Log Message: Teld now reads $UTS_DIR/etc/teld.conf to see how to run telgo. Index: main.c =================================================================== RCS file: /cvsroot/uts/uts/src/tel/teld/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 22:50:03 -0000 1.3 *************** *** 17,20 **** --- 17,21 ---- #include <stdio.h> #include <stdlib.h> + #include <string.h> #include <signal.h> #include <setjmp.h> *************** *** 35,43 **** { tel_info *tel; printf("\nTelescope daemon ver. 0.01sec - secretary version.\n\n"); ! /* useless, just to get rid of Efence message */ ! free(malloc(1)); printf("Jumping into background\n"); --- 36,54 ---- { tel_info *tel; + char *uts_dir; + char tmpbuf[256]; + FILE *conffile; + printf("\nTelescope daemon ver. 0.01sec - secretary version.\n\n"); ! uts_dir = getenv("UTS_DIR"); ! snprintf(tmpbuf, 255, "%s/etc/teld.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"); *************** *** 48,51 **** --- 59,64 ---- tel = init_tel(ftelstat); if (tel == NULL) exit(-1); + tel->child_cmdline = calloc(strlen(tmpbuf)+1, sizeof(char)); + strcpy(tel->child_cmdline, tmpbuf); tel_loop(tel); Index: runchild.c =================================================================== RCS file: /cvsroot/uts/uts/src/tel/teld/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:03:21 -0000 1.1.1.1 --- runchild.c 9 Mar 2004 22:50:03 -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/tel/teld/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:03:21 -0000 1.1.1.1 --- runchild.h 9 Mar 2004 22:50:03 -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 */ Index: tel.h =================================================================== RCS file: /cvsroot/uts/uts/src/tel/teld/tel.h,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** tel.h 29 Jan 2004 03:03:21 -0000 1.1.1.1 --- tel.h 9 Mar 2004 22:50:03 -0000 1.2 *************** *** 49,52 **** --- 49,53 ---- teltask_t *task; + char *child_cmdline; int chpid; char *childfname; Index: tel_task.c =================================================================== RCS file: /cvsroot/uts/uts/src/tel/teld/tel_task.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** tel_task.c 29 Jan 2004 03:03:21 -0000 1.1.1.1 --- tel_task.c 9 Mar 2004 22:50:03 -0000 1.2 *************** *** 35,41 **** { int chpid; setstatus(tel->ginfo->sec, TEL_INSTNAME, finststatus[IST_BUSY]); ! printf("-> Exec task: Spawning child process.\n"); if (chargs == NULL) chargs = alloc_chargs(6); --- 35,42 ---- { int chpid; + char cmdline[256]; setstatus(tel->ginfo->sec, TEL_INSTNAME, finststatus[IST_BUSY]); ! /* old stuff printf("-> Exec task: Spawning child process.\n"); if (chargs == NULL) chargs = alloc_chargs(6); *************** *** 48,53 **** printf("-> Moving to RA: %s - DEC: %s...\n", tel->task->ra, tel->task->dec); ! /* fork processess */ ! chpid = spawn_child(tel->childfname, chargs); setstatus(tel->ginfo->sec, TEL_MOVING, S_TRUE); --- 49,60 ---- printf("-> Moving to RA: %s - DEC: %s...\n", tel->task->ra, tel->task->dec); ! */ ! ! /* build command line */ ! snprintf(cmdline, 255, tel->child_cmdline, ! tel->task->ra, tel->task->dec); ! ! /* fork processess */ ! chpid = spawn_child(cmdline); setstatus(tel->ginfo->sec, TEL_MOVING, S_TRUE); |