1 /* Support for ignoring SIGTTOU.
3 Copyright (C) 2003-2023 Free Software Foundation, Inc.
5 This file is part of GDB.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
20 #ifndef SCOPED_IGNORE_SIGTTOU_H
21 #define SCOPED_IGNORE_SIGTTOU_H
23 #include "gdbsupport/scoped_ignore_signal.h"
24 #include "gdbsupport/job-control.h"
28 /* Simple wrapper that allows lazy initialization / destruction of T.
29 Slightly more efficient than gdb::optional, because it doesn't
30 carry storage to track whether the object has been initialized. */
48 /* Must define ctor/dtor if T has non-trivial ctor/dtor. */
56 /* RAII class used to ignore SIGTTOU in a scope. This isn't simply
57 scoped_ignore_signal<SIGTTOU> because we want to check the
58 `job_control' global. */
60 class scoped_ignore_sigttou
63 scoped_ignore_sigttou ()
66 m_ignore_signal
.emplace ();
69 ~scoped_ignore_sigttou ()
72 m_ignore_signal
.reset ();
75 DISABLE_COPY_AND_ASSIGN (scoped_ignore_sigttou
);
78 lazy_init
<scoped_ignore_signal
<SIGTTOU
, false>> m_ignore_signal
;
83 using scoped_ignore_sigttou
= scoped_ignore_signal_nop
;
87 #endif /* SCOPED_IGNORE_SIGTTOU_H */