mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-02 01:45:17 +00:00
examples: Work around lack of mingw sigaction()
mingw lacks sigaction(); we were getting it from gnulib. But since commit acf522e8 stopped linking examples against gnulib, we are getting a build failure. Keep the examples standalone, and work around mingw by using signal() instead. Signed-off-by: Eric Blake <eblake@redhat.com> Reviewed-by: John Ferlan <jferlan@redhat.com>
This commit is contained in:
parent
358b6b593e
commit
414afc8dbe
@ -266,10 +266,6 @@ do_top(virConnectPtr conn,
|
|||||||
int max_id = 0;
|
int max_id = 0;
|
||||||
int nparams = 0, then_nparams = 0, now_nparams = 0;
|
int nparams = 0, then_nparams = 0, now_nparams = 0;
|
||||||
virTypedParameterPtr then_params = NULL, now_params = NULL;
|
virTypedParameterPtr then_params = NULL, now_params = NULL;
|
||||||
struct sigaction action_stop;
|
|
||||||
|
|
||||||
memset(&action_stop, 0, sizeof(action_stop));
|
|
||||||
action_stop.sa_handler = stop;
|
|
||||||
|
|
||||||
/* Lookup the domain */
|
/* Lookup the domain */
|
||||||
if (!(dom = virDomainLookupByName(conn, dom_name))) {
|
if (!(dom = virDomainLookupByName(conn, dom_name))) {
|
||||||
@ -295,8 +291,10 @@ do_top(virConnectPtr conn,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
sigaction(SIGTERM, &action_stop, NULL);
|
/* The ideal program would use sigaction to set this handler, but
|
||||||
sigaction(SIGINT, &action_stop, NULL);
|
* this way is portable to mingw. */
|
||||||
|
signal(SIGTERM, stop);
|
||||||
|
signal(SIGINT, stop);
|
||||||
|
|
||||||
run_top = true;
|
run_top = true;
|
||||||
while (run_top) {
|
while (run_top) {
|
||||||
|
@ -1147,13 +1147,8 @@ main(int argc, char **argv)
|
|||||||
virConnectPtr dconn = NULL;
|
virConnectPtr dconn = NULL;
|
||||||
int callback1ret = -1;
|
int callback1ret = -1;
|
||||||
int callback16ret = -1;
|
int callback16ret = -1;
|
||||||
struct sigaction action_stop;
|
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
memset(&action_stop, 0, sizeof(action_stop));
|
|
||||||
|
|
||||||
action_stop.sa_handler = stop;
|
|
||||||
|
|
||||||
if (argc > 1 && STREQ(argv[1], "--help")) {
|
if (argc > 1 && STREQ(argv[1], "--help")) {
|
||||||
printf("%s uri\n", argv[0]);
|
printf("%s uri\n", argv[0]);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -1184,8 +1179,10 @@ main(int argc, char **argv)
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
sigaction(SIGTERM, &action_stop, NULL);
|
/* The ideal program would use sigaction to set this handler, but
|
||||||
sigaction(SIGINT, &action_stop, NULL);
|
* this way is portable to mingw. */
|
||||||
|
signal(SIGTERM, stop);
|
||||||
|
signal(SIGINT, stop);
|
||||||
|
|
||||||
printf("Registering event callbacks\n");
|
printf("Registering event callbacks\n");
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user