summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrediano Ziglio <fziglio@redhat.com>2019-12-12 21:34:12 +0000
committerFrediano Ziglio <fziglio@redhat.com>2019-12-12 21:35:58 +0000
commit85fc0b5482fe3df8e4c8b09088bbde24680d5816 (patch)
treed42945370a5cf3430b38863113a2a739a4b99387
parent725141836af4a6489f4147c306434271986824d0 (diff)
vdservice: Print error on standard error, not standard output
Error stream should be used for error reporting, not output one. Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
-rw-r--r--vdservice/vdservice.cpp26
1 files changed, 13 insertions, 13 deletions
diff --git a/vdservice/vdservice.cpp b/vdservice/vdservice.cpp
index 7564fbb..2a547cf 100644
--- a/vdservice/vdservice.cpp
+++ b/vdservice/vdservice.cpp
@@ -151,13 +151,13 @@ bool VDService::install()
SC_HANDLE service_control_manager = OpenSCManager(0, 0, SC_MANAGER_CREATE_SERVICE);
if (!service_control_manager) {
- printf("OpenSCManager failed\n");
+ fprintf(stderr, "OpenSCManager failed\n");
return false;
}
TCHAR path[_MAX_PATH + 2];
DWORD len = GetModuleFileName(0, path + 1, _MAX_PATH);
if (len == 0 || len == _MAX_PATH) {
- printf("GetModuleFileName failed\n");
+ fprintf(stderr, "GetModuleFileName failed\n");
CloseServiceHandle(service_control_manager);
return false;
}
@@ -173,7 +173,7 @@ bool VDService::install()
SERVICE_DESCRIPTION descr;
descr.lpDescription = const_cast<LPTSTR>(VD_SERVICE_DESCRIPTION);
if (!ChangeServiceConfig2(service, SERVICE_CONFIG_DESCRIPTION, &descr)) {
- printf("ChangeServiceConfig2 failed\n");
+ fprintf(stderr, "ChangeServiceConfig2 failed\n");
}
CloseServiceHandle(service);
printf("Service installed successfully\n");
@@ -182,7 +182,7 @@ bool VDService::install()
printf("Service already exists\n");
ret = true;
} else {
- printf("Service not installed successfully, error %lu\n", GetLastError());
+ fprintf(stderr, "Service not installed successfully, error %lu\n", GetLastError());
}
CloseServiceHandle(service_control_manager);
return ret;
@@ -194,34 +194,34 @@ bool VDService::uninstall()
SC_HANDLE service_control_manager = OpenSCManager(0, 0, SC_MANAGER_CONNECT);
if (!service_control_manager) {
- printf("OpenSCManager failed\n");
+ fprintf(stderr, "OpenSCManager failed\n");
return false;
}
SC_HANDLE service = OpenService(service_control_manager, VD_SERVICE_NAME,
SERVICE_QUERY_STATUS | DELETE);
if (!service) {
- printf("OpenService failed\n");
+ fprintf(stderr, "OpenService failed\n");
CloseServiceHandle(service_control_manager);
return false;
}
SERVICE_STATUS status;
if (!QueryServiceStatus(service, &status)) {
- printf("QueryServiceStatus failed\n");
+ fprintf(stderr, "QueryServiceStatus failed\n");
} else if (status.dwCurrentState != SERVICE_STOPPED) {
- printf("Service is still running\n");
+ fprintf(stderr, "Service is still running\n");
} else if (DeleteService(service)) {
printf("Service removed successfully\n");
ret = true;
} else {
switch (GetLastError()) {
case ERROR_ACCESS_DENIED:
- printf("Access denied while trying to remove service\n");
+ fprintf(stderr, "Access denied while trying to remove service\n");
break;
case ERROR_INVALID_HANDLE:
- printf("Handle invalid while trying to remove service\n");
+ fprintf(stderr, "Handle invalid while trying to remove service\n");
break;
case ERROR_SERVICE_MARKED_FOR_DELETE:
- printf("Service already marked for deletion\n");
+ fprintf(stderr, "Service already marked for deletion\n");
break;
}
}
@@ -820,7 +820,7 @@ int _tmain(int argc, TCHAR* argv[])
bool success = false;
if (!supported_system_version()) {
- printf("vdservice is not supported in this system version\n");
+ fprintf(stderr, "vdservice is not supported in this system version\n");
return -1;
}
if (argc > 1) {
@@ -829,7 +829,7 @@ int _tmain(int argc, TCHAR* argv[])
} else if (lstrcmpi(argv[1], TEXT("uninstall")) == 0) {
success = VDService::uninstall();
} else {
- printf("Use: vdservice install / uninstall\n");
+ fprintf(stderr, "Use: vdservice install / uninstall\n");
}
} else {
success = VDService::run();