]> git.ipfire.org Git - thirdparty/squid.git/blame - src/unlinkd_daemon.cc
Renamed squid.h to squid-old.h and config.h to squid.h
[thirdparty/squid.git] / src / unlinkd_daemon.cc
CommitLineData
128fe1c6 1/*
262a0e14 2 * $Id$
128fe1c6 3 *
b510f3a1 4 * DEBUG: section -- Unlink Daemon
128fe1c6 5 * AUTHOR: Duane Wessels
6 *
7 * SQUID Web Proxy Cache http://www.squid-cache.org/
8 * ----------------------------------------------------------
9 *
10 * Squid is the result of efforts by numerous individuals from
11 * the Internet community; see the CONTRIBUTORS file for full
12 * details. Many organizations have provided support for Squid's
13 * development; see the SPONSORS file for full details. Squid is
14 * Copyrighted (C) 2001 by the Regents of the University of
15 * California; see the COPYRIGHT file for full details. Squid
16 * incorporates software developed and/or copyrighted by other
17 * sources; see the CREDITS file for full details.
18 *
19 * This program is free software; you can redistribute it and/or modify
20 * it under the terms of the GNU General Public License as published by
21 * the Free Software Foundation; either version 2 of the License, or
22 * (at your option) any later version.
26ac0430 23 *
128fe1c6 24 * This program is distributed in the hope that it will be useful,
25 * but WITHOUT ANY WARRANTY; without even the implied warranty of
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27 * GNU General Public License for more details.
26ac0430 28 *
128fe1c6 29 * You should have received a copy of the GNU General Public License
30 * along with this program; if not, write to the Free Software
31 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
32 *
33 */
34
35#define SQUID_HELPER 1
36
f7f3304a 37#include "squid.h"
25f98340
AJ
38
39#if HAVE_PATHS_H
40#include <paths.h>
41#endif
128fe1c6 42
63be0a78 43/**
44 \defgroup unlinkd unlinkd
45 \ingroup ExternalPrograms
46 \par
47 The unlink(2) system call can cause a process to block
48 for a significant amount of time. Therefore we do not want
49 to make unlink() calls from Squid. Instead we pass them
50 to this external process.
51 */
128fe1c6 52
63be0a78 53/// \ingroup unlinkd
128fe1c6 54#define UNLINK_BUF_LEN 1024
55
63be0a78 56/**
57 \ingroup unlinkd
58 \par This is the unlinkd external process.
59 *
60 \par
61 * unlinkd receives the full path of any files to be removed
62 * from stdin, each on its own line.
63 *
64 \par
65 * The results for each file are printed to stdout in the order
66 * they were received
67 *
68 \param argc Ignored.
69 \param argv Ignored.
70 \retval ERR An error occured removing the file.
71 \retval OK The file has been removed.
72 */
128fe1c6 73int
74main(int argc, char *argv[])
75{
76 char buf[UNLINK_BUF_LEN];
77 char *t;
78 int x;
79 setbuf(stdin, NULL);
80 setbuf(stdout, NULL);
81 close(2);
82 open(_PATH_DEVNULL, O_RDWR);
83
84 while (fgets(buf, UNLINK_BUF_LEN, stdin)) {
85 if ((t = strchr(buf, '\n')))
86 *t = '\0';
87 x = unlink(buf);
88 if (x < 0)
89 printf("ERR\n");
90 else
91 printf("OK\n");
92 }
93
25f98340 94 return 0;
128fe1c6 95}