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