]> jfr.im git - irc.git/blame - software/!RELEASES/ircservices/achurch.org/services/lists/ircservices-coding/2002/000847.html
RELEASE -> !RELEASE
[irc.git] / software / !RELEASES / ircservices / achurch.org / services / lists / ircservices-coding / 2002 / 000847.html
CommitLineData
3bd189cb
JR
1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
2<HTML>
3 <HEAD>
4 <TITLE> [IRCServices Coding] Crontab Script
5 </TITLE>
6 <LINK REL="Index" HREF="index.html" >
7 <LINK REL="made" HREF="mailto:ircservices-coding%40ircservices.za.net?Subject=%5BIRCServices%20Coding%5D%20Crontab%20Script&In-Reply-To=c3.23367af9.2a20c919%40aol.com">
8 <META NAME="robots" CONTENT="index,nofollow">
9 <META http-equiv="Content-Type" content="text/html; charset=us-ascii">
10 <LINK REL="Previous" HREF="000764.html">
11 <LINK REL="Next" HREF="000769.html">
12 </HEAD>
13 <BODY BGCOLOR="#ffffff">
14 <H1>[IRCServices Coding] Crontab Script</H1>
15 <B>V13</B>
16 <A HREF="mailto:ircservices-coding%40ircservices.za.net?Subject=%5BIRCServices%20Coding%5D%20Crontab%20Script&In-Reply-To=c3.23367af9.2a20c919%40aol.com"
17 TITLE="[IRCServices Coding] Crontab Script">v13 at it.teithe.gr
18 </A><BR>
19 <I>Sun Jun 2 05:37:03 PDT 2002</I>
20 <P><UL>
21 <LI>Previous message: <A HREF="000764.html">[IRCServices Coding] Crontab Script
22</A></li>
23 <LI>Next message: <A HREF="000769.html">[IRCServices Coding] SQL DB
24</A></li>
25 <LI> <B>Messages sorted by:</B>
26 <a href="date.html#847">[ date ]</a>
27 <a href="thread.html#847">[ thread ]</a>
28 <a href="subject.html#847">[ subject ]</a>
29 <a href="author.html#847">[ author ]</a>
30 </LI>
31 </UL>
32 <HR>
33<!--beginarticle-->
34<PRE> Andrew, I suppose you can include/use the attached code (or any modified
35version of it) in services, without causing portability problems. It will
36solve the pidfile problem and the need of a keepalive script. It just creates
37and locks the pidfile using an advisory lock. This way it stays locked while
38services are running. OS will unlock it if services die. I'm currently using
39it in some progs of mine without any problems. It seems to compile and work
40on linux, freebsd, irix and solaris without problems. Since this is a
41modified version of the one i'm using, this may be incorect.
42
43 There are 3 functions. pidfile_islocked(), pidfile_dolock(),
44pidfile_dounlock(). That check for a lock, lock and unlock the pidfile. They
45also create and remove the pidfile. I'm also using pidfile_islocked to get
46the current pid of the running copy. This way I can kill the running copy
47when the program is run with (for exampe) '-k' by
48
49pid=pidfile_islocked(PIDFILE);
50if (pid)
51 kill(pid,SIGTERM);
52
53 In case of fork(), you have to call pidfile_islocked() once before the fork()
54is done and pidfile_dolock() after the fork, so that the lock will not go
55away. I'm attaching an example program too.
56
57 There exists a race condition, but i prefer this from the one that exist in
58every keepalive script.
59
60&lt;&lt;V13&gt;&gt;
61-------------- next part --------------
62A non-text attachment was scrubbed...
63Name: example.c
64Type: text/x-csrc
65Size: 301 bytes
66Desc: not available
67Url : <A HREF="../attachments/20020602/3c6a97c2/example.c">../attachments/20020602/3c6a97c2/example.c</A>
68-------------- next part --------------
69A non-text attachment was scrubbed...
70Name: pidfile.c
71Type: text/x-csrc
72Size: 2338 bytes
73Desc: not available
74Url : <A HREF="../attachments/20020602/3c6a97c2/pidfile.c">../attachments/20020602/3c6a97c2/pidfile.c</A>
75</PRE>
76
77<!--endarticle-->
78 <HR>
79 <P><UL>
80 <!--threads-->
81 <LI>Previous message: <A HREF="000764.html">[IRCServices Coding] Crontab Script
82</A></li>
83 <LI>Next message: <A HREF="000769.html">[IRCServices Coding] SQL DB
84</A></li>
85 <LI> <B>Messages sorted by:</B>
86 <a href="date.html#847">[ date ]</a>
87 <a href="thread.html#847">[ thread ]</a>
88 <a href="subject.html#847">[ subject ]</a>
89 <a href="author.html#847">[ author ]</a>
90 </LI>
91 </UL>
92
93</body></html>