提交 6bf55a97 编写于 作者: D Daniel P. Berrange

Don't assume pid_t is the same size as an int

virPidFileReadPathIfAlive passed in an 'int *' where a 'pid_t *'
was expected, which breaks on Mingw64 targets. Also a few places
were using '%d' for formatting pid_t, change them to '%lld' and
force a cast to the longer type as done elsewhere in the same
file.
Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
上级 eb0b42d8
......@@ -206,7 +206,7 @@ int virPidFileReadPathIfAlive(const char *path,
pid_t *pid,
const char *binPath)
{
int ret, retPid;
int ret;
bool isLink;
char *procPath = NULL;
char *procLink = NULL;
......@@ -215,7 +215,7 @@ int virPidFileReadPathIfAlive(const char *path,
char *resolvedProcLink = NULL;
const char deletedText[] = " (deleted)";
size_t deletedTextLen = strlen(deletedText);
pid_t retPid;
/* only set this at the very end on success */
*pid = -1;
......
......@@ -250,7 +250,7 @@ virProcessKillPainfully(pid_t pid, bool force)
int i, ret = -1;
const char *signame = "TERM";
VIR_DEBUG("vpid=%d force=%d", pid, force);
VIR_DEBUG("vpid=%lld force=%d", (long long)pid, force);
/* This loop sends SIGTERM, then waits a few iterations (10 seconds)
* to see if it dies. If the process still hasn't exited, and
......@@ -265,8 +265,8 @@ virProcessKillPainfully(pid_t pid, bool force)
if (i == 0) {
signum = SIGTERM; /* kindly suggest it should exit */
} else if ((i == 50) & force) {
VIR_DEBUG("Timed out waiting after SIGTERM to process %d, "
"sending SIGKILL", pid);
VIR_DEBUG("Timed out waiting after SIGTERM to process %lld, "
"sending SIGKILL", (long long)pid);
/* No SIGKILL kill on Win32 ! Use SIGABRT instead which our
* virProcessKill proc will handle more or less like SIGKILL */
#ifdef WIN32
......@@ -283,8 +283,8 @@ virProcessKillPainfully(pid_t pid, bool force)
if (virProcessKill(pid, signum) < 0) {
if (errno != ESRCH) {
virReportSystemError(errno,
_("Failed to terminate process %d with SIG%s"),
pid, signame);
_("Failed to terminate process %lld with SIG%s"),
(long long)pid, signame);
goto cleanup;
}
ret = signum == SIGTERM ? 0 : 1;
......@@ -294,7 +294,8 @@ virProcessKillPainfully(pid_t pid, bool force)
usleep(200 * 1000);
}
VIR_DEBUG("Timed out waiting after SIGKILL to process %d", pid);
VIR_DEBUG("Timed out waiting after SIGKILL to process %lld",
(long long)pid);
cleanup:
return ret;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册