]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/unlinkd_daemon.cc
2 * Copyright (C) 1996-2018 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
22 \defgroup unlinkd unlinkd
23 \ingroup ExternalPrograms
25 The unlink(2) system call can cause a process to block
26 for a significant amount of time. Therefore we do not want
27 to make unlink() calls from Squid. Instead we pass them
28 to this external process.
32 #define UNLINK_BUF_LEN 1024
36 \par This is the unlinkd external process.
39 * unlinkd receives the full path of any files to be removed
40 * from stdin, each on its own line.
43 * The results for each file are printed to stdout in the order
48 \retval ERR An error occured removing the file.
49 \retval OK The file has been removed.
56 if (open(_PATH_DEVNULL
, O_RDWR
) < 0) {
57 ; // the irony of having to close(2) earlier is that we cannot report this failure.
59 while (getline(std::cin
, sbuf
)) {
60 // tailing newline is removed by getline
61 const int rv
= remove(sbuf
.c_str());
63 std::cout
<< "ERR" << std::endl
; // endl flushes
65 std::cout
<< "OK" << std::endl
;