blob: 317da446aa8724245b0f81d5663136b6f19131d8 [file] [log] [blame]
Erik Kline85890042018-05-25 19:19:11 +09001/*
2 * Copyright (C) 2018 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef NETD_SERVER_PROCESS_H_
18#define NETD_SERVER_PROCESS_H_
19
Luke Huangb257d612019-03-14 21:19:13 +080020#include "netdutils/DumpWriter.h"
Erik Kline85890042018-05-25 19:19:11 +090021
22#include <string>
23
24namespace android {
25namespace net {
26namespace process {
27
28// Does what is says on the tin.
29void blockSigPipe();
30
31void writePidFile(const std::string& pidFile);
32void removePidFile(const std::string& pidFile);
33
34class ScopedPidFile {
35 public:
36 ScopedPidFile() = delete;
37 ScopedPidFile(const std::string& filename) : pidFile(filename) {
38 removePidFile(pidFile);
39 writePidFile(pidFile);
40 }
41 ScopedPidFile(const ScopedPidFile&) = delete;
42 ScopedPidFile(ScopedPidFile&&) = delete;
43
44 ~ScopedPidFile() {
45 removePidFile(pidFile);
46 }
47
48 ScopedPidFile& operator=(const ScopedPidFile&) = delete;
49 ScopedPidFile& operator=(ScopedPidFile&&) = delete;
50
51 const std::string pidFile;
52};
53
Luke Huangb257d612019-03-14 21:19:13 +080054void dump(netdutils::DumpWriter& dw);
Erik Kline85890042018-05-25 19:19:11 +090055
56} // namespace process
57} // namespace net
58} // namespace android
59
60#endif // NETD_SERVER_PROCESS_H_