]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/unlinkd_daemon.cc
2 * Copyright (C) 1996-2014 The Squid Software Foundation and contributors
4 * Squid software is distributed under GPLv2+ license and includes
5 * contributions from numerous individuals and organizations.
6 * Please see the COPYING and CONTRIBUTORS files for details.
9 /* DEBUG: section -- Unlink Daemon */
11 #define SQUID_HELPER 1
20 \defgroup unlinkd unlinkd
21 \ingroup ExternalPrograms
23 The unlink(2) system call can cause a process to block
24 for a significant amount of time. Therefore we do not want
25 to make unlink() calls from Squid. Instead we pass them
26 to this external process.
30 #define UNLINK_BUF_LEN 1024
34 \par This is the unlinkd external process.
37 * unlinkd receives the full path of any files to be removed
38 * from stdin, each on its own line.
41 * The results for each file are printed to stdout in the order
46 \retval ERR An error occured removing the file.
47 \retval OK The file has been removed.
50 main(int argc
, char *argv
[])
52 char buf
[UNLINK_BUF_LEN
];
58 if (open(_PATH_DEVNULL
, O_RDWR
) < 0) {
59 ; // the irony of having to close(2) earlier is that we cannot report this failure.
62 while (fgets(buf
, sizeof(buf
), stdin
)) {
63 if ((t
= strchr(buf
, '\n')))