diff options
author | qwerty <qwerty@yandex-team.ru> | 2022-02-10 16:49:25 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:49:25 +0300 |
commit | ca6b8a0150d5ee4cc8fb804d1285d9c32fb4fe88 (patch) | |
tree | 5d5cb817648f650d76cf1076100726fd9b8448e8 /util | |
parent | 34e37ee57f5837a8da2fdfaccaac9bbe6c7f02ba (diff) | |
download | ydb-ca6b8a0150d5ee4cc8fb804d1285d9c32fb4fe88.tar.gz |
Restoring authorship annotation for <qwerty@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'util')
-rw-r--r-- | util/charset/generated/unidata.cpp | 8 | ||||
-rw-r--r-- | util/charset/unicode_table.h | 2 | ||||
-rw-r--r-- | util/charset/unidata.h | 6 | ||||
-rw-r--r-- | util/charset/wide_ut.cpp | 6 | ||||
-rw-r--r-- | util/datetime/cputimer.h | 2 | ||||
-rw-r--r-- | util/datetime/strptime.cpp | 14 | ||||
-rw-r--r-- | util/draft/holder_vector.h | 2 | ||||
-rw-r--r-- | util/draft/matrix.h | 2 | ||||
-rw-r--r-- | util/draft/memory_ut.cpp | 4 | ||||
-rw-r--r-- | util/folder/dirent_win.c | 4 | ||||
-rw-r--r-- | util/folder/filelist_ut.cpp | 2 | ||||
-rw-r--r-- | util/folder/lstat_win.c | 4 | ||||
-rw-r--r-- | util/folder/path.cpp | 2 | ||||
-rw-r--r-- | util/folder/path.h | 4 | ||||
-rw-r--r-- | util/generic/maybe.h | 2 | ||||
-rw-r--r-- | util/generic/string_ut.cpp | 10 | ||||
-rw-r--r-- | util/network/socket.cpp | 28 | ||||
-rw-r--r-- | util/stream/pipe.cpp | 4 | ||||
-rw-r--r-- | util/stream/pipe.h | 2 | ||||
-rw-r--r-- | util/string/cast_ut.cpp | 2 | ||||
-rw-r--r-- | util/system/backtrace.cpp | 2 | ||||
-rw-r--r-- | util/system/daemon.cpp | 126 | ||||
-rw-r--r-- | util/system/daemon.h | 10 | ||||
-rw-r--r-- | util/system/defaults.h | 2 | ||||
-rw-r--r-- | util/system/error.cpp | 2 | ||||
-rw-r--r-- | util/system/progname.cpp | 8 | ||||
-rw-r--r-- | util/system/progname.h | 4 | ||||
-rw-r--r-- | util/ysaveload.h | 4 |
28 files changed, 134 insertions, 134 deletions
diff --git a/util/charset/generated/unidata.cpp b/util/charset/generated/unidata.cpp index ca55dbb48d..6f5adbbc0a 100644 --- a/util/charset/generated/unidata.cpp +++ b/util/charset/generated/unidata.cpp @@ -2,7 +2,7 @@ namespace { namespace NUnidataTableGenerated { using TV = const NUnicode::NPrivate::TUnidataTable::TStored; - + static const TV V[] = { #undef V0 #define V0 (*(V + 0)) @@ -1646,7 +1646,7 @@ namespace { namespace NUnidataTableGenerated { #define V546 (*(V + 546)) {0x2F002, 0, -34, -34, 0}, }; - + static const NUnicode::NPrivate::TUnidataTable::TValuePtr P[][32] = { { &V0, &V0, &V0, &V0, &V0, &V0, &V0, &V0, @@ -5339,7 +5339,7 @@ namespace { namespace NUnidataTableGenerated { &V485, &V485, &V485, &V485, &V485, &V485, }, // P[614] }; // static const NUnicode::NPrivate::TUnidataTable::TValuePtr P[][32] - + static const NUnicode::NPrivate::TUnidataTable::TValuePtr* const Indexes[] = { P[0], P[1], P[2], P[3], P[4], P[5], P[6], P[7], P[8], P[9], P[10], P[11], P[12], P[13], P[14], P[15], P[16], P[17], P[18], P[19], P[20], P[21], P[22], P[23], P[24], P[25], P[26], P[27], P[28], P[29], P[30], P[31], @@ -7518,7 +7518,7 @@ namespace { namespace NUnidataTableGenerated { P[360], P[360], P[360], P[360], P[360], P[360], P[360], P[360], P[360], P[360], P[360], P[360], P[360], P[360], P[360], P[360], P[360], P[360], P[360], P[360], P[360], P[360], P[360], P[360], P[360], P[360], P[360], P[360], P[360], P[360], P[360], P[614], }; // static const NUnicode::NPrivate::TUnidataTable::TValuePtr* const Indexes[] - + static const size_t Size = 1114110; }} // namespace NUnidataTableGenerated diff --git a/util/charset/unicode_table.h b/util/charset/unicode_table.h index 6850ee769e..9e171b2583 100644 --- a/util/charset/unicode_table.h +++ b/util/charset/unicode_table.h @@ -5,7 +5,7 @@ #include <util/generic/typetraits.h> namespace NUnicodeTable { - template <class Value> + template <class Value> struct TValueSelector; template <class Value> diff --git a/util/charset/unidata.h b/util/charset/unidata.h index 08fc632027..400d314186 100644 --- a/util/charset/unidata.h +++ b/util/charset/unidata.h @@ -195,7 +195,7 @@ inline bool IsHyphen(wchar32 ch) { return NUnicode::CharHasType(ch, SHIFT(Pd_HYPHEN) | SHIFT(Po_HYPHEN)); } inline bool IsQuotation(wchar32 ch) { - return NUnicode::CharHasType(ch, + return NUnicode::CharHasType(ch, SHIFT(Po_QUOTE) | SHIFT(Ps_QUOTE) | SHIFT(Pe_QUOTE) | SHIFT(Pi_QUOTE) | SHIFT(Pf_QUOTE) | SHIFT(Po_SINGLE_QUOTE) | SHIFT(Ps_SINGLE_QUOTE) | SHIFT(Pe_SINGLE_QUOTE) | SHIFT(Pi_SINGLE_QUOTE) | SHIFT(Pf_SINGLE_QUOTE)); @@ -211,7 +211,7 @@ inline bool IsTerminal(wchar32 ch) { return NUnicode::CharHasType(ch, SHIFT(Po_TERMINAL)); } inline bool IsPairedPunct(wchar32 ch) { - return NUnicode::CharHasType(ch, + return NUnicode::CharHasType(ch, SHIFT(Ps_START) | SHIFT(Pe_END) | SHIFT(Ps_QUOTE) | SHIFT(Pe_QUOTE) | SHIFT(Pi_QUOTE) | SHIFT(Pf_QUOTE) | SHIFT(Ps_SINGLE_QUOTE) | SHIFT(Pe_SINGLE_QUOTE) | SHIFT(Pi_SINGLE_QUOTE) | SHIFT(Pf_SINGLE_QUOTE)); @@ -229,7 +229,7 @@ inline bool IsNonspacing(wchar32 ch) { return NUnicode::CharHasType(ch, SHIFT(Mn_NONSPACING) | SHIFT(Me_ENCLOSING)); } inline bool IsAlphabetic(wchar32 ch) { - return NUnicode::CharHasType(ch, + return NUnicode::CharHasType(ch, SHIFT(Lu_UPPER) | SHIFT(Ll_LOWER) | SHIFT(Lt_TITLE) | SHIFT(Lm_EXTENDER) | SHIFT(Lm_LETTER) | SHIFT(Lo_OTHER) | SHIFT(Nl_LETTER)); } inline bool IsIdeographic(wchar32 ch) { diff --git a/util/charset/wide_ut.cpp b/util/charset/wide_ut.cpp index aada2170d0..d8f3233e73 100644 --- a/util/charset/wide_ut.cpp +++ b/util/charset/wide_ut.cpp @@ -793,7 +793,7 @@ public: void TestIsSpace() { UNIT_ASSERT(!IsSpace(TUtf16String())); - + UNIT_ASSERT(IsSpace(ws, Y_ARRAY_SIZE(ws))); TUtf16String w; @@ -886,11 +886,11 @@ public: temp = original; temp.to_lower(); UNIT_ASSERT(temp == lower); - + temp = original; ToLower(temp.begin(), temp.size()); UNIT_ASSERT(temp == lower); - + temp = original; temp.to_upper(); UNIT_ASSERT(temp == upper); diff --git a/util/datetime/cputimer.h b/util/datetime/cputimer.h index f5f9449b4a..7d38d5bdb3 100644 --- a/util/datetime/cputimer.h +++ b/util/datetime/cputimer.h @@ -118,7 +118,7 @@ private: public: TTimeLogger(const TString& message, bool verbose = true); ~TTimeLogger(); - + void SetOK(); double ElapsedTime() const; }; diff --git a/util/datetime/strptime.cpp b/util/datetime/strptime.cpp index cf6acf2445..f0d4ec333e 100644 --- a/util/datetime/strptime.cpp +++ b/util/datetime/strptime.cpp @@ -5,20 +5,20 @@ * Powerdog Industries kindly requests feedback from anyone modifying * this function: * - * Date: Thu, 05 Jun 1997 23:17:17 -0400 + * Date: Thu, 05 Jun 1997 23:17:17 -0400 * From: Kevin Ruddy <kevin.ruddy@powerdog.com> * To: James FitzGibbon <james@nexis.net> * Subject: Re: Use of your strptime(3) code (fwd) - * + * * The reason for the "no mod" clause was so that modifications would - * come back and we could integrate them and reissue so that a wider - * audience could use it (thereby spreading the wealth). This has + * come back and we could integrate them and reissue so that a wider + * audience could use it (thereby spreading the wealth). This has * made it possible to get strptime to work on many operating systems. * I'm not sure why that's "plain unacceptable" to the FreeBSD team. - * + * * Anyway, you can change it to "with or without modification" as - * you see fit. Enjoy. - * + * you see fit. Enjoy. + * * Kevin Ruddy * Powerdog Industries, Inc. */ diff --git a/util/draft/holder_vector.h b/util/draft/holder_vector.h index 634228fe46..1c62055bd9 100644 --- a/util/draft/holder_vector.h +++ b/util/draft/holder_vector.h @@ -70,7 +70,7 @@ public: (*this)[i] = nullptr; return t; } - + void Resize(size_t newSize) { for (size_t i = newSize; i < size(); ++i) { D::Destroy((*this)[i]); diff --git a/util/draft/matrix.h b/util/draft/matrix.h index 2947ca473e..154d00b35e 100644 --- a/util/draft/matrix.h +++ b/util/draft/matrix.h @@ -94,7 +94,7 @@ public: void Zero() { memset((void*)Arr, 0, M * N * sizeof(T)); } - + void Fill(T value) { for (T *p = Arr, *end = Arr + M * N; p < end; ++p) *p = value; diff --git a/util/draft/memory_ut.cpp b/util/draft/memory_ut.cpp index e5160c5c40..76bee30549 100644 --- a/util/draft/memory_ut.cpp +++ b/util/draft/memory_ut.cpp @@ -29,7 +29,7 @@ Y_UNIT_TEST_SUITE(TUtilDraftMemoryTest) { UNIT_ASSERT(IsZero(a1)); a1 = 0xF0; UNIT_ASSERT(!IsZero(a1)); - + i32 a2 = -1; UNIT_ASSERT(!IsZero(a2)); a2 = 0; @@ -39,7 +39,7 @@ Y_UNIT_TEST_SUITE(TUtilDraftMemoryTest) { UNIT_ASSERT(IsZero(a3)); a3 = 1.e-13; UNIT_ASSERT(!IsZero(a3)); - + TSampleStruct1 ss1; ss1.A = 0; ss1.B = 0; diff --git a/util/folder/dirent_win.c b/util/folder/dirent_win.c index 3e6f00a239..7e6db74ce5 100644 --- a/util/folder/dirent_win.c +++ b/util/folder/dirent_win.c @@ -32,7 +32,7 @@ struct DIR* opendir(const char* dirname) { int len = strlen(dirname); //Remove trailing slashes while (len && (dirname[len - 1] == '\\' || dirname[len - 1] == '/')) { - --len; + --len; } int len_converted = MultiByteToWideChar(CP_UTF8, 0, dirname, len, 0, 0); if (len_converted == 0) { @@ -80,7 +80,7 @@ int readdir_r(struct DIR* dir, struct dirent* entry, struct dirent** result) { } entry->d_fileno = dir->file_no++; entry->d_reclen = sizeof(struct dirent); - if (dir->wfd.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT && + if (dir->wfd.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT && (dir->wfd.dwReserved0 == IO_REPARSE_TAG_MOUNT_POINT || dir->wfd.dwReserved0 == IO_REPARSE_TAG_SYMLINK)) { entry->d_type = DT_LNK; diff --git a/util/folder/filelist_ut.cpp b/util/folder/filelist_ut.cpp index e5eb096c45..0cdcdf3d00 100644 --- a/util/folder/filelist_ut.cpp +++ b/util/folder/filelist_ut.cpp @@ -22,7 +22,7 @@ void TFileListTest::TestSimple() { TTempDir tempDir("nonexistingdir"); MakeDirIfNotExist((tempDir() + LOCSLASH_S "subdir").data()); TFile((tempDir() + LOCSLASH_S "subdir" LOCSLASH_S "file").data(), CreateAlways); - + TFileList fileList; fileList.Fill(tempDir().data(), "", "", 1000); TString fileName(fileList.Next()); diff --git a/util/folder/lstat_win.c b/util/folder/lstat_win.c index d5bb64ede4..cf94cec01a 100644 --- a/util/folder/lstat_win.c +++ b/util/folder/lstat_win.c @@ -3,7 +3,7 @@ #ifdef _win_ #include <util/system/winint.h> #include "lstat_win.h" - + int lstat(const char* fileName, stat_struct* fileStat) { int len = strlen(fileName); int convRes = MultiByteToWideChar(CP_UTF8, 0, fileName, len, 0, 0); @@ -21,7 +21,7 @@ int lstat(const char* fileName, stat_struct* fileStat) { if (result == 0) { SetLastError(0); findHandle = FindFirstFileW(buf, &findBuf); - if (findBuf.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT && + if (findBuf.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT && (findBuf.dwReserved0 == IO_REPARSE_TAG_MOUNT_POINT || findBuf.dwReserved0 == IO_REPARSE_TAG_SYMLINK)) { fileStat->st_mode = fileStat->st_mode & ~_S_IFMT | _S_IFLNK; diff --git a/util/folder/path.cpp b/util/folder/path.cpp index 96682b9cbd..bfe0c67d68 100644 --- a/util/folder/path.cpp +++ b/util/folder/path.cpp @@ -70,7 +70,7 @@ TFsPath TFsPath::RelativeTo(const TFsPath& root) const { if (!this->IsSubpathOf(root)) { ythrow TIoException() << "path " << *this << " is not subpath of " << root; } - + split.erase(split.begin(), split.begin() + rsplit.size()); split.IsAbsolute = false; diff --git a/util/folder/path.h b/util/folder/path.h index ef78ffcfc0..2fb4d6b4ef 100644 --- a/util/folder/path.h +++ b/util/folder/path.h @@ -87,7 +87,7 @@ public: bool IsAbsolute() const; bool IsRelative() const; - + /** * TFsPath("/a/b").IsSubpathOf("/a") -> true * @@ -125,7 +125,7 @@ public: * Never fails. Returns this if already a root. */ TFsPath Parent() const; - + TString Basename() const { return GetName(); } diff --git a/util/generic/maybe.h b/util/generic/maybe.h index 9e70b39a08..34d21aebcd 100644 --- a/util/generic/maybe.h +++ b/util/generic/maybe.h @@ -38,7 +38,7 @@ template <class T, class Policy /*= ::NMaybe::TPolicyUndefinedExcept*/> class TMaybe: private TMaybeBase<T> { public: using TInPlace = NMaybe::TInPlace; - + private: static_assert(!std::is_same<std::remove_cv_t<T>, TNothing>::value, "Instantiation of TMaybe with a TNothing type is ill-formed"); diff --git a/util/generic/string_ut.cpp b/util/generic/string_ut.cpp index df4f95afe9..ac82e9091d 100644 --- a/util/generic/string_ut.cpp +++ b/util/generic/string_ut.cpp @@ -815,13 +815,13 @@ public: UNIT_TEST_SUITE_END(); private: - void TestDecodingMethods() { + void TestDecodingMethods() { UNIT_ASSERT(TUtf16String::FromAscii("").empty()); UNIT_ASSERT(TUtf16String::FromAscii("abc") == ASCIIToWide("abc")); const char* text = "123kx83abcd ej)#$%ddja&%J&"; TUtf16String wtext = ASCIIToWide(text); - + UNIT_ASSERT(wtext == TUtf16String::FromAscii(text)); TString strtext(text); @@ -829,7 +829,7 @@ private: TStringBuf strbuftext(text); UNIT_ASSERT(wtext == TUtf16String::FromAscii(strbuftext)); - + UNIT_ASSERT(wtext.substr(5) == TUtf16String::FromAscii(text + 5)); const wchar16 wideCyrillicAlphabet[] = { @@ -859,12 +859,12 @@ private: UNIT_ASSERT(s1 == wtext); // append - + TUtf16String s2; TUtf16String testAppend = strWide; s2.AppendUtf8(strUtf8); UNIT_ASSERT(testAppend == s2); - + testAppend += ' '; s2.AppendAscii(" "); UNIT_ASSERT(testAppend == s2); diff --git a/util/network/socket.cpp b/util/network/socket.cpp index f3a3e79ac8..4f6e804346 100644 --- a/util/network/socket.cpp +++ b/util/network/socket.cpp @@ -610,28 +610,28 @@ private: TOps* Ops_; }; -template <> +template <> void Out<const struct addrinfo*>(IOutputStream& os, const struct addrinfo* ai) { if (ai->ai_flags & AI_CANONNAME) { - os << "`" << ai->ai_canonname << "' "; + os << "`" << ai->ai_canonname << "' "; } - - os << '['; + + os << '['; for (int i = 0; ai; ++i, ai = ai->ai_next) { if (i > 0) { - os << ", "; + os << ", "; } - + os << (const IRemoteAddr&)TAddrInfo(ai); - } - os << ']'; -} - -template <> + } + os << ']'; +} + +template <> void Out<struct addrinfo*>(IOutputStream& os, struct addrinfo* ai) { Out<const struct addrinfo*>(os, static_cast<const struct addrinfo*>(ai)); -} - +} + template <> void Out<TNetworkAddress>(IOutputStream& os, const TNetworkAddress& addr) { os << &*addr.Begin(); @@ -647,7 +647,7 @@ static inline const struct addrinfo* Iterate(const struct addrinfo* addr, const static inline SOCKET DoConnectImpl(const struct addrinfo* res, const TInstant& deadLine) { const struct addrinfo* addr0 = res; - + while (res) { TSocketHolder s(socket(res->ai_family, res->ai_socktype, res->ai_protocol)); diff --git a/util/stream/pipe.cpp b/util/stream/pipe.cpp index e197560a93..51be1934a7 100644 --- a/util/stream/pipe.cpp +++ b/util/stream/pipe.cpp @@ -93,7 +93,7 @@ TPipedBase::~TPipedBase() { } } -TPipedInput::TPipedInput(PIPEHANDLE fd) +TPipedInput::TPipedInput(PIPEHANDLE fd) : TPipedBase(fd) { } @@ -104,7 +104,7 @@ size_t TPipedInput::DoRead(void* buf, size_t len) { if (!Handle_.IsOpen()) { return 0; } - return Handle_.Read(buf, len); + return Handle_.Read(buf, len); } TPipedOutput::TPipedOutput(PIPEHANDLE fd) diff --git a/util/stream/pipe.h b/util/stream/pipe.h index 427eee0afd..18525b9517 100644 --- a/util/stream/pipe.h +++ b/util/stream/pipe.h @@ -80,7 +80,7 @@ class TPipedBase { protected: TPipedBase(PIPEHANDLE fd); virtual ~TPipedBase(); - + protected: TPipeHandle Handle_; }; diff --git a/util/string/cast_ut.cpp b/util/string/cast_ut.cpp index cd02a36f19..033450c38c 100644 --- a/util/string/cast_ut.cpp +++ b/util/string/cast_ut.cpp @@ -42,7 +42,7 @@ template <class A> struct TRet { - template <int base> + template <int base> inline A IntFromStringForCheck(const TString& str) { return IntFromString<A, base>(str); } diff --git a/util/system/backtrace.cpp b/util/system/backtrace.cpp index d726803ac3..b77fe58fb1 100644 --- a/util/system/backtrace.cpp +++ b/util/system/backtrace.cpp @@ -73,7 +73,7 @@ namespace { TBackTraceContext* bt = (TBackTraceContext*)h; if (bt->cnt != 0) { - bt->sym[bt->cnt - 1] = (void*)_Unwind_GetIP(c); + bt->sym[bt->cnt - 1] = (void*)_Unwind_GetIP(c); } if (bt->cnt == bt->size) { diff --git a/util/system/daemon.cpp b/util/system/daemon.cpp index 8f58813c52..130e6c8f45 100644 --- a/util/system/daemon.cpp +++ b/util/system/daemon.cpp @@ -18,7 +18,7 @@ using namespace NDaemonMaker; static bool Fork(EParent parent) { - pid_t pid = fork(); + pid_t pid = fork(); if (pid > 0) { int status = 0; @@ -30,11 +30,11 @@ static bool Fork(EParent parent) { return true; } } else if (pid < 0) { - ythrow TSystemError() << "Cannot fork"; + ythrow TSystemError() << "Cannot fork"; } if (setsid() < 0) { - ythrow TSystemError() << "Cannot setsid"; + ythrow TSystemError() << "Cannot setsid"; } pid = fork(); @@ -42,24 +42,24 @@ static bool Fork(EParent parent) { if (pid > 0) { _exit(0); } else if (pid < 0) { - ythrow TSystemError() << "Cannot second fork"; + ythrow TSystemError() << "Cannot second fork"; } return false; } -#endif - +#endif + static void CloseFromToExcept(int from, int to, const int* except) { (void)from; (void)to; (void)except; -#ifdef _unix_ +#ifdef _unix_ int mfd = NSystemInfo::MaxOpenFiles(); - for (int s = from; s < mfd && (to == -1 || s < to); s++) { + for (int s = from; s < mfd && (to == -1 || s < to); s++) { for (const int* ex = except; *ex >= 0; ++ex) { if (s == *ex) { - goto dontclose; + goto dontclose; } } while (close(s) == -1) { @@ -71,98 +71,98 @@ static void CloseFromToExcept(int from, int to, const int* except) { } } dontclose:; - } + } #endif /* _unix_ */ } - + bool NDaemonMaker::MakeMeDaemon(ECloseDescriptors cd, EStdIoDescriptors iod, EChDir chd, EParent parent) { (void)cd; (void)iod; (void)chd; -#ifdef _unix_ +#ifdef _unix_ if (Fork(parent)) { return true; } - + if (chd == chdirRoot) { if (chdir("/")) { ythrow TSystemError() << "chdir(\"/\") failed"; } } - + int fd[4] = {-1, -1, -1, -1}; switch (iod) { - case openYandexStd: - fd[0] = open("yandex.stdin", O_RDONLY); + case openYandexStd: + fd[0] = open("yandex.stdin", O_RDONLY); if (fd[0] < 0) { - ythrow TSystemError() << "Cannot open 'yandex.stdin'"; + ythrow TSystemError() << "Cannot open 'yandex.stdin'"; } - fd[1] = open("yandex.stdout", O_WRONLY | O_APPEND | O_CREAT, 660); + fd[1] = open("yandex.stdout", O_WRONLY | O_APPEND | O_CREAT, 660); if (fd[1] < 0) { - ythrow TSystemError() << "Cannot open 'yandex.stdout'"; + ythrow TSystemError() << "Cannot open 'yandex.stdout'"; } - fd[2] = open("yandex.stderr", O_WRONLY | O_APPEND | O_CREAT, 660); + fd[2] = open("yandex.stderr", O_WRONLY | O_APPEND | O_CREAT, 660); if (fd[2] < 0) { - ythrow TSystemError() << "Cannot open 'yandex.stderr'"; + ythrow TSystemError() << "Cannot open 'yandex.stderr'"; } - break; - case openDevNull: - fd[0] = open("/dev/null", O_RDWR, 0); - break; - case openNone: - break; - default: - ythrow yexception() << "Unknown open descriptors mode: " << (int)iod; - } - - const int except[4] = { - fd[0], - fd[1], - fd[2], + break; + case openDevNull: + fd[0] = open("/dev/null", O_RDWR, 0); + break; + case openNone: + break; + default: + ythrow yexception() << "Unknown open descriptors mode: " << (int)iod; + } + + const int except[4] = { + fd[0], + fd[1], + fd[2], -1}; if (closeAll == cd) { - CloseFromToExcept(0, -1, except); + CloseFromToExcept(0, -1, except); } else if (closeStdIoOnly == cd) { - CloseFromToExcept(0, 3, except); + CloseFromToExcept(0, 3, except); } else { - ythrow yexception() << "Unknown close descriptors mode: " << (int)cd; + ythrow yexception() << "Unknown close descriptors mode: " << (int)cd; } - + switch (iod) { - case openYandexStd: - /* Assuming that open(2) acquires fds in order. */ - dup2(fd[0], STDIN_FILENO); + case openYandexStd: + /* Assuming that open(2) acquires fds in order. */ + dup2(fd[0], STDIN_FILENO); if (fd[0] > 2) { - close(fd[0]); + close(fd[0]); } - dup2(fd[1], STDOUT_FILENO); + dup2(fd[1], STDOUT_FILENO); if (fd[1] > 2) { - close(fd[1]); + close(fd[1]); } - dup2(fd[2], STDERR_FILENO); + dup2(fd[2], STDERR_FILENO); if (fd[2] > 2) { - close(fd[2]); + close(fd[2]); } - break; - case openDevNull: - dup2(fd[0], STDIN_FILENO); - dup2(fd[0], STDOUT_FILENO); - dup2(fd[0], STDERR_FILENO); + break; + case openDevNull: + dup2(fd[0], STDIN_FILENO); + dup2(fd[0], STDOUT_FILENO); + dup2(fd[0], STDERR_FILENO); if (fd[0] > 2) { - close(fd[0]); + close(fd[0]); } - break; - default: - break; - } + break; + default: + break; + } return false; #else return true; -#endif -} - -void NDaemonMaker::CloseFrom(int fd) { +#endif +} + +void NDaemonMaker::CloseFrom(int fd) { static const int except[1] = {-1}; - CloseFromToExcept(fd, -1, except); -} + CloseFromToExcept(fd, -1, except); +} diff --git a/util/system/daemon.h b/util/system/daemon.h index 01a5d319ce..b00793b9c9 100644 --- a/util/system/daemon.h +++ b/util/system/daemon.h @@ -12,11 +12,11 @@ namespace NDaemonMaker { openYandexStd }; - enum EChDir { - chdirNone = 0, - chdirRoot - }; - + enum EChDir { + chdirNone = 0, + chdirRoot + }; + enum EParent { callExitFromParent = 0, returnFromParent diff --git a/util/system/defaults.h b/util/system/defaults.h index 7633fc7dd1..dcd7abea38 100644 --- a/util/system/defaults.h +++ b/util/system/defaults.h @@ -143,7 +143,7 @@ constexpr bool Y_IS_DEBUG_BUILD = true; #define Y_STRINGIZE(X) UTIL_PRIVATE_STRINGIZE_AUX(X) #define UTIL_PRIVATE_STRINGIZE_AUX(X) #X - + #if defined(__COUNTER__) #define Y_GENERATE_UNIQUE_ID(N) Y_CAT(N, __COUNTER__) #endif diff --git a/util/system/error.cpp b/util/system/error.cpp index a38abb0263..f778ec42cb 100644 --- a/util/system/error.cpp +++ b/util/system/error.cpp @@ -19,7 +19,7 @@ void ClearLastSystemError() { #if defined(_win_) SetLastError(0); -#else +#else errno = 0; #endif } diff --git a/util/system/progname.cpp b/util/system/progname.cpp index 6b0ed56bff..2c29119320 100644 --- a/util/system/progname.cpp +++ b/util/system/progname.cpp @@ -5,7 +5,7 @@ #include <util/generic/singleton.h> static const char* Argv0; - + namespace { struct TProgramNameHolder { inline TProgramNameHolder() @@ -20,7 +20,7 @@ namespace { const TString& GetProgramName() { return Singleton<TProgramNameHolder>()->ProgName; } - + void SetProgramName(const char* argv0) { - Argv0 = argv0; -} + Argv0 = argv0; +} diff --git a/util/system/progname.h b/util/system/progname.h index 75788605e5..e5e2a0eee2 100644 --- a/util/system/progname.h +++ b/util/system/progname.h @@ -3,11 +3,11 @@ #include <util/generic/fwd.h> void SetProgramName(const char* argv0); - + #define SAVE_PROGRAM_NAME \ do { \ SetProgramName(argv[0]); \ } while (0) - + /// guaranted return the same immutable instance of TString const TString& GetProgramName(); diff --git a/util/ysaveload.h b/util/ysaveload.h index 6d0dfa4d3f..02efb4049b 100644 --- a/util/ysaveload.h +++ b/util/ysaveload.h @@ -461,7 +461,7 @@ public: { S_.clear(); } - + inline void Insert(const TValue& v) { S_.insert(v); } @@ -493,7 +493,7 @@ public: Y_UNUSED(cnt); P_ = this->S_.begin(); } - + inline void Insert(const TValue& v) { P_ = this->S_.insert(P_, v); } |