unlinkd_daemon.cc
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1996-2023 The Squid Software Foundation and contributors
3  *
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.
7  */
8 
9 /* DEBUG: section -- Unlink Daemon */
10 
11 #define SQUID_HELPER 1
12 
13 #include "squid.h"
14 
15 #include <iostream>
16 #include <cstdio>
17 #if HAVE_PATHS_H
18 #include <paths.h>
19 #endif
20 
31 #define UNLINK_BUF_LEN 1024
33 
51 int
52 main(int, char *[])
53 {
54  std::string sbuf;
55  close(2);
56  if (open(_PATH_DEVNULL, O_RDWR) < 0) {
57  ; // the irony of having to close(2) earlier is that we cannot report this failure.
58  }
59  while (getline(std::cin, sbuf)) {
60  // tailing newline is removed by getline
61  const int rv = remove(sbuf.c_str());
62  if (rv < 0)
63  std::cout << "ERR" << std::endl; // endl flushes
64  else
65  std::cout << "OK" << std::endl;
66  }
67 
68  return EXIT_SUCCESS;
69 }
70 
int main(int, char *[])

 

Introduction

Documentation

Support

Miscellaneous