Patch #: 10 Type: bug fix Priority: medium Affects: sites periodically deleting lwsrv log file Reported: Rakesh Patel Archived: munnari.OZ.AU mac/cap.patches/cap60.patch010 Summary: log file only opened once at startup File: cap60/applications/lwsrv/lwsrv.c *** applications/lwsrv/lwsrv.c.orig Tue May 7 23:45:03 1991 --- applications/lwsrv/lwsrv.c Wed May 8 00:09:59 1991 *************** *** 1,6 **** ! static char rcsid[] = "$Author: djh $ $Date: 1991/05/06 15:03:58 $"; ! static char rcsident[] = "$Header: /mac/src/cap60/applications/lwsrv/RCS/lwsrv.c,v 2.4 1991/05/06 15:03:58 djh Exp djh $"; ! static char revision[] = "$Revision: 2.4 $"; /* * lwsrv - UNIX AppleTalk spooling program: act as a laserwriter --- 1,6 ---- ! static char rcsid[] = "$Author: djh $ $Date: 1991/05/07 14:09:39 $"; ! static char rcsident[] = "$Header: /mac/src/cap60/applications/lwsrv/RCS/lwsrv.c,v 2.5 1991/05/07 14:09:39 djh Exp djh $"; ! static char revision[] = "$Revision: 2.5 $"; /* * lwsrv - UNIX AppleTalk spooling program: act as a laserwriter *************** *** 280,285 **** --- 280,312 ---- exit(0); } + openlogfile() + { + int i; + + if (logfile != NULL) { + if ((i = open(logfile,O_WRONLY|O_APPEND)) < 0) + i = creat(logfile,0666); + if (i != 2) { + #ifndef NODUP2 + (void) dup2(i,2); + #else NODUP2 + close(2); /* try again */ + (void) dup(0); /* for slot 2 */ + #endif NODUP2 + (void) close(i); + } + #ifdef LWSRV_LPR_LOG /* Set up logfile to be also stdout/stderr for lpr */ + #ifdef NODUP2 + close(1); + dup(2); + #else NODUP2 + dup2 (2, 1); + #endif NODUP2 + #endif LWSRV_LPR_LOG + } + } + main(argc,argv) int argc; char **argv; *************** *** 322,348 **** #else NODUP2 (void) dup(0); /* for slot 2 */ #endif NODUP2 ! } else { ! if ((i = open(logfile,O_WRONLY|O_APPEND)) < 0) ! i = creat(logfile,0666); ! if (i != 2) { ! #ifndef NODUP2 ! (void) dup2(i,2); ! #else NODUP2 ! close(2); /* try again */ ! (void) dup(0); /* for slot 2 */ ! #endif NODUP2 ! (void) close(i); ! } ! #ifdef LWSRV_LPR_LOG /* Set up logfile to be also stdout/stderr for lpr */ ! #ifdef NODUP2 ! close(1); ! dup(2); ! #else NODUP2 ! dup2 (2, 1); ! #endif NODUP2 ! #endif LWSRV_LPR_LOG ! } #ifdef TIOCNOTTY if ((i = open("/dev/tty",2)) > 0) { ioctl(i, TIOCNOTTY,(char *) 0); --- 349,356 ---- #else NODUP2 (void) dup(0); /* for slot 2 */ #endif NODUP2 ! } else ! openlogfile(); #ifdef TIOCNOTTY if ((i = open("/dev/tty",2)) > 0) { ioctl(i, TIOCNOTTY,(char *) 0); *************** *** 388,393 **** --- 396,402 ---- #ifdef LWSRV_AUFS_SECURITY AddrBlock addr; /* budd */ #endif LWSRV_AUFS_SECURITY + openlogfile(); NewStatus("idle"); err = GetNextJob(srefnum, &cno, &rcomp); if (err != noErr) { *************** *** 472,477 **** --- 481,488 ---- #endif LWSRV_AUFS_SECURITY if (!singlefork) { + if (logfile != NULL) + close(2); /* close log file */ if (fork() != 0) { PAPShutdown(cno); /* kill off connection */ continue; *************** *** 481,486 **** --- 492,498 ---- } else NewStatus("busy, processing job"); /* need for multi-forking, nice for single forking */ /* handle the connection in cno */ + openlogfile(); signal(SIGCHLD,SIG_IGN); childjob(p_opn(cno, BUFMAX)); if (!singlefork) *** README.orig Wed May 8 20:53:43 1991 --- README Wed May 8 20:53:57 1991 *************** *** 3,9 **** (For use with AppleTalk/Ethernet bridge) o RELEASE NOTES ! o CAP Distribution 6.0, Patch Level 9, May 1991 Introduction ------------ --- 3,9 ---- (For use with AppleTalk/Ethernet bridge) o RELEASE NOTES ! o CAP Distribution 6.0, Patch Level 10, May 1991 Introduction ------------