bundle.c (64602637c707aae391347ee750092412f64b28fc) bundle.c (5284761414ce1ef5f00cb7e3f93076682b591a5e)
1/*-
2 * Copyright (c) 1998 Brian Somers <brian@Awfulhak.org>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 631 unchanged lines hidden (view full) ---

640
641 return result;
642}
643
644void
645bundle_LockTun(struct bundle *bundle)
646{
647 FILE *lockfile;
1/*-
2 * Copyright (c) 1998 Brian Somers <brian@Awfulhak.org>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 631 unchanged lines hidden (view full) ---

640
641 return result;
642}
643
644void
645bundle_LockTun(struct bundle *bundle)
646{
647 FILE *lockfile;
648 char pidfile[MAXPATHLEN];
648 char pidfile[PATH_MAX];
649
650 snprintf(pidfile, sizeof pidfile, "%stun%d.pid", _PATH_VARRUN, bundle->unit);
651 lockfile = ID0fopen(pidfile, "w");
652 if (lockfile != NULL) {
653 fprintf(lockfile, "%d\n", (int)getpid());
654 fclose(lockfile);
655 }
656#ifndef RELEASE_CRUNCH
657 else
658 log_Printf(LogERROR, "Warning: Can't create %s: %s\n",
659 pidfile, strerror(errno));
660#endif
661}
662
663static void
664bundle_UnlockTun(struct bundle *bundle)
665{
649
650 snprintf(pidfile, sizeof pidfile, "%stun%d.pid", _PATH_VARRUN, bundle->unit);
651 lockfile = ID0fopen(pidfile, "w");
652 if (lockfile != NULL) {
653 fprintf(lockfile, "%d\n", (int)getpid());
654 fclose(lockfile);
655 }
656#ifndef RELEASE_CRUNCH
657 else
658 log_Printf(LogERROR, "Warning: Can't create %s: %s\n",
659 pidfile, strerror(errno));
660#endif
661}
662
663static void
664bundle_UnlockTun(struct bundle *bundle)
665{
666 char pidfile[MAXPATHLEN];
666 char pidfile[PATH_MAX];
667
668 snprintf(pidfile, sizeof pidfile, "%stun%d.pid", _PATH_VARRUN, bundle->unit);
669 ID0unlink(pidfile);
670}
671
672struct bundle *
673bundle_Create(const char *prefix, int type, int unit)
674{

--- 1382 unchanged lines hidden ---
667
668 snprintf(pidfile, sizeof pidfile, "%stun%d.pid", _PATH_VARRUN, bundle->unit);
669 ID0unlink(pidfile);
670}
671
672struct bundle *
673bundle_Create(const char *prefix, int type, int unit)
674{

--- 1382 unchanged lines hidden ---