Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
F
FMC TDC 1ns 5cha - Software
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
FMC TDC 1ns 5cha - Software
Commits
969d7208
Commit
969d7208
authored
Apr 09, 2015
by
Federico Vaga
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tools: handle sigint signal
Signed-off-by:
Federico Vaga
<
federico.vaga@cern.ch
>
parent
198ac041
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
2 deletions
+20
-2
fmc-tdc-tstamp.c
tools/fmc-tdc-tstamp.c
+20
-2
No files found.
tools/fmc-tdc-tstamp.c
View file @
969d7208
...
...
@@ -21,6 +21,7 @@
#include <unistd.h>
#include <fcntl.h>
#include <inttypes.h>
#include <signal.h>
#include <getopt.h>
...
...
@@ -28,6 +29,7 @@
/* Previous time stamp for each channel */
struct
fmctdc_time
ts_prev
[
FMCTDC_NUM_CHANNELS
];
static
unsigned
int
stop
=
0
;
void
dump_timestamp
(
struct
fmctdc_time
ts
,
int
fmt_wr
)
...
...
@@ -111,6 +113,12 @@ static void tstamp_flush(struct fmctdc_board *brd, int ch, int flush)
ch
,
fmctdc_strerror
(
errno
));
}
static
void
termination_handler
(
int
signum
)
{
fprintf
(
stderr
,
"
\n
fmc-tdc-tstamp: killing application
\n
"
);
stop
=
1
;
}
int
main
(
int
argc
,
char
**
argv
)
{
struct
fmctdc_board
*
brd
;
...
...
@@ -124,7 +132,16 @@ int main(int argc, char **argv)
int
fmt_wr
=
0
,
flush
=
0
,
read
=
0
;
char
opt
;
fd_set
rfds
;
struct
sigaction
new_action
,
old_action
;
/* Set up the structure to specify the new action. */
new_action
.
sa_handler
=
termination_handler
;
sigemptyset
(
&
new_action
.
sa_mask
);
new_action
.
sa_flags
=
0
;
sigaction
(
SIGINT
,
NULL
,
&
old_action
);
if
(
old_action
.
sa_handler
!=
SIG_IGN
)
sigaction
(
SIGINT
,
&
new_action
,
NULL
);
atexit
(
fmctdc_exit
);
/* Initialize FMC TDC library */
...
...
@@ -242,7 +259,8 @@ int main(int argc, char **argv)
fmctdc_set_acquisition
(
brd
,
1
);
/* Read Time-Stamps */
n
=
0
;
while
(
n
<
n_samples
||
n_samples
<=
0
)
{
while
((
n
<
n_samples
||
n_samples
<=
0
)
&&
(
!
stop
))
{
/* Check for pending signal */
nfds
=
0
;
/* Prepare the list of channel to observe */
...
...
@@ -264,7 +282,7 @@ int main(int argc, char **argv)
if
(
!
nblock
&&
ret
<=
0
)
{
if
(
ret
<
0
)
fprintf
(
stderr
,
"Error while waiting for timestamp: %s"
,
"Error while waiting for timestamp: %s
\n
"
,
strerror
(
errno
));
continue
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment