Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dune-xt
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ag-ohlberger
dune-community
dune-xt
Commits
58b2639f
Commit
58b2639f
authored
14 years ago
by
René Fritze
Browse files
Options
Downloads
Patches
Plain Diff
documentation and generalisation of signals
parent
32725d2a
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
stuff/signals.hh
+10
-3
10 additions, 3 deletions
stuff/signals.hh
with
10 additions
and
3 deletions
stuff/signals.hh
+
10
−
3
View file @
58b2639f
...
...
@@ -7,6 +7,8 @@
namespace
Stuff
{
namespace
Signals
{
//! reset given signal to default handler
void
resetSignal
(
int
signal
)
{
struct
sigaction
new_action
;
...
...
@@ -16,6 +18,7 @@ void resetSignal(int signal)
sigaction
(
signal
,
&
new_action
,
NULL
);
}
//! example signal handler
void
handleInterrupt
(
int
signal
)
{
Logger
().
Info
()
<<
"forcefully terminated at "
<<
Logging
::
TimeString
()
<<
std
::
endl
;
...
...
@@ -25,16 +28,20 @@ void handleInterrupt(int signal)
kill
(
getpid
(),
signal
);
}
void
installSignalHandlers
()
//! type of handler functions
typedef
void
handler_type
(
int
);
//! calling this from your main() will install handler as callback when signal is received
void
installSignalHandler
(
int
signal
=
SIGINT
,
handler_type
handler
=
handleInterrupt
)
{
struct
sigaction
new_action
;
/* Set up the structure to specify the new action. */
new_action
.
sa_handler
=
handle
Interrupt
;
new_action
.
sa_handler
=
handle
r
;
sigemptyset
(
&
new_action
.
sa_mask
);
new_action
.
sa_flags
=
0
;
sigaction
(
SIGINT
,
&
new_action
,
NULL
);
sigaction
(
signal
,
&
new_action
,
NULL
);
}
}
// end namespace signals
}
// end namepsace stuff
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment