Console: toggle terminal echo based on presence of interactive child processes (dotne...
[platform/upstream/dotnet/runtime.git] / src / libraries / Native / Unix / System.Native / pal_signal.h
1 // Licensed to the .NET Foundation under one or more agreements.
2 // The .NET Foundation licenses this file to you under the MIT license.
3 // See the LICENSE file in the project root for more information.
4
5 #pragma once
6
7 #include "pal_compiler.h"
8 #include "pal_types.h"
9
10 /**
11  * Initializes the signal handling, called by InitializeTerminalAndSignalHandling.
12  *
13  * Returns 1 on success; otherwise returns 0 and sets errno.
14  */
15 int32_t InitializeSignalHandlingCore(void);
16
17 /**
18  * Hooks up the specified callback for notifications when SIGINT or SIGQUIT is received.
19  *
20  * Not thread safe.  Caller must provide its owns synchronization to ensure RegisterForCtrl
21  * is not called concurrently with itself or with UnregisterForCtrl.
22  *
23  * Should only be called when a callback is not currently registered.
24  */
25 DLLEXPORT void SystemNative_RegisterForCtrl(CtrlCallback callback);
26
27 /**
28  * Unregisters the previously registered ctrlCCallback.
29  *
30  * Not thread safe.  Caller must provide its owns synchronization to ensure UnregisterForCtrl
31  * is not called concurrently with itself or with RegisterForCtrl.
32  *
33  * Should only be called when a callback is currently registered. The pointer
34  * previously registered must remain valid until all ctrl handling activity
35  * has quiesced.
36  */
37 DLLEXPORT void SystemNative_UnregisterForCtrl(void);
38
39 typedef void (*SigChldCallback)(int reapAll);
40
41 /**
42  * Hooks up the specified callback for notifications when SIGCHLD is received.
43  *
44  * Should only be called when a callback is not currently registered.
45  */
46 DLLEXPORT void SystemNative_RegisterForSigChld(SigChldCallback callback);
47
48 /**
49  * Remove our handler and reissue the signal to be picked up by the previously registered handler.
50  *
51  * In the most common case, this will be the default handler, causing the process to be torn down.
52  * It could also be a custom handler registered by other code before us.
53  */
54 DLLEXPORT void SystemNative_RestoreAndHandleCtrl(CtrlCode ctrlCode);
55
56 typedef void (*TerminalInvalidationCallback)(void);
57
58 /**
59  * Hooks up the specified callback for notifications when SIGCHLD, SIGCONT, SIGWINCH are received.
60   *
61  */
62 DLLEXPORT void SystemNative_SetTerminalInvalidationHandler(TerminalInvalidationCallback callback);