Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
ORNL Quantum Computing Institute
xacc
Commits
8c776c19
Commit
8c776c19
authored
Feb 19, 2018
by
Mccaskey, Alex
Browse files
adding better ctrl-c handling
Signed-off-by:
Alex McCaskey
<
mccaskeyaj@ornl.gov
>
parent
0cbe9b0d
Changes
2
Hide whitespace changes
Inline
Side-by-side
xacc/XACC.cpp
View file @
8c776c19
...
...
@@ -12,6 +12,8 @@
*******************************************************************************/
#include
"XACC.hpp"
#include
"InstructionIterator.hpp"
#include
<signal.h>
#include
<cstdlib>
namespace
xacc
{
...
...
@@ -45,6 +47,12 @@ bool isInitialized() {
return
xaccFrameworkInitialized
;
}
void
ctrl_c_handler
(
int
signal
)
{
error
(
"Caught CTRL-C, exiting the framework."
);
Finalize
();
exit
(
1
);
}
void
Initialize
(
int
arc
,
char
**
arv
)
{
if
(
!
xaccFrameworkInitialized
)
{
...
...
@@ -61,7 +69,7 @@ void Initialize(int arc, char** arv) {
XACCLogger
::
instance
()
->
error
(
"Failure initializing XACC Plugin Registry - "
+
std
::
string
(
e
.
what
()));
Finalize
();
exit
(
-
1
);
exit
(
1
);
}
// Parse any user-supplied command line options
...
...
@@ -80,6 +88,11 @@ void Initialize(int arc, char** arv) {
"[xacc::plugins] XACC has "
+
std
::
to_string
(
a
)
+
" Accelerator"
+
((
s
==
0
||
s
==
1
)
?
""
:
"s"
)
+
" available."
);
struct
sigaction
sigIntHandler
;
sigIntHandler
.
sa_handler
=
ctrl_c_handler
;
sigemptyset
(
&
sigIntHandler
.
sa_mask
);
sigIntHandler
.
sa_flags
=
0
;
sigaction
(
SIGINT
,
&
sigIntHandler
,
NULL
);
}
// We're good if we make it here, so indicate that we've been
...
...
xacc/XACC.hpp
View file @
8c776c19
...
...
@@ -221,6 +221,18 @@ std::shared_ptr<Compiler> getCompiler();
*/
bool
hasCompiler
(
const
std
::
string
&
name
);
template
<
typename
Service
>
std
::
shared_ptr
<
Service
>
getService
(
const
std
::
string
&
serviceName
)
{
auto
service
=
ServiceRegistry
::
instance
()
->
getService
<
Service
>
(
serviceName
);
if
(
!
service
)
{
error
(
"Invalid XACC Service. Could not find "
+
serviceName
+
" in Service Registry."
);
}
return
service
;
}
std
::
shared_ptr
<
IRTransformation
>
getIRTransformation
(
const
std
::
string
&
name
);
const
std
::
string
translate
(
const
std
::
string
&
original
,
const
std
::
string
&
originalLanguageName
,
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment