projects
/
oweals
/
gnunet.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
doxygen docu
[oweals/gnunet.git]
/
contrib
/
timeout_watchdog_w32.c
diff --git
a/contrib/timeout_watchdog_w32.c
b/contrib/timeout_watchdog_w32.c
index 286d39a94cef60596057af87132776accb6dbe45..d5117d71ff2c2b4829f7236a52de65ac073ecf4a 100644
(file)
--- a/
contrib/timeout_watchdog_w32.c
+++ b/
contrib/timeout_watchdog_w32.c
@@
-37,7
+37,6
@@
main (int argc, char *argv[])
wchar_t **wargv;
wchar_t *arg;
unsigned int cmdlen;
wchar_t **wargv;
wchar_t *arg;
unsigned int cmdlen;
- wchar_t *idx;
STARTUPINFOW start;
PROCESS_INFORMATION proc;
STARTUPINFOW start;
PROCESS_INFORMATION proc;
@@
-50,6
+49,7
@@
main (int argc, char *argv[])
wchar_t *wcmd;
int wargc;
int timeout = 0;
wchar_t *wcmd;
int wargc;
int timeout = 0;
+ ssize_t wrote;
HANDLE job;
HANDLE job;
@@
-100,7
+100,7
@@
main (int argc, char *argv[])
if (cmdlen < 5 || wcscmp (&wargv[2][cmdlen - 4], L".exe") != 0)
{
non_const_filename = malloc (sizeof (wchar_t) * (cmdlen + 5));
if (cmdlen < 5 || wcscmp (&wargv[2][cmdlen - 4], L".exe") != 0)
{
non_const_filename = malloc (sizeof (wchar_t) * (cmdlen + 5));
-
_snwprintf (non_const_filename, cmdlen + 5, L"%s
.exe", wargv[2]);
+
swprintf (non_const_filename, cmdlen + 5, L"%S
.exe", wargv[2]);
}
else
{
}
else
{
@@
-109,7
+109,7
@@
main (int argc, char *argv[])
/* Check that this is the full path. If it isn't, search. */
if (non_const_filename[1] == L':')
/* Check that this is the full path. If it isn't, search. */
if (non_const_filename[1] == L':')
-
_snwprintf (wpath, sizeof (wpath) / sizeof (wchar_t), L"%s
", non_const_filename);
+
swprintf (wpath, sizeof (wpath) / sizeof (wchar_t), L"%S
", non_const_filename);
else if (!SearchPathW
(pathbuf, non_const_filename, NULL, sizeof (wpath) / sizeof (wchar_t),
wpath, NULL))
else if (!SearchPathW
(pathbuf, non_const_filename, NULL, sizeof (wpath) / sizeof (wchar_t),
wpath, NULL))
@@
-125,22
+125,25
@@
main (int argc, char *argv[])
while (NULL != (arg = wargv[i++]))
cmdlen += wcslen (arg) + 4;
while (NULL != (arg = wargv[i++]))
cmdlen += wcslen (arg) + 4;
- wcmd = idx = malloc (sizeof (wchar_t) * (cmdlen + 1));
+ wcmd = malloc (sizeof (wchar_t) * (cmdlen + 1));
+ wrote = 0;
i = 2;
while (NULL != (arg = wargv[i++]))
{
/* This is to escape trailing slash */
wchar_t arg_lastchar = arg[wcslen (arg) - 1];
i = 2;
while (NULL != (arg = wargv[i++]))
{
/* This is to escape trailing slash */
wchar_t arg_lastchar = arg[wcslen (arg) - 1];
- if (idx == wcmd)
- idx += swprintf (idx, L"\"%s%s\" ", wpath,
+ if (wrote == 0)
+ {
+ wrote += swprintf (&wcmd[wrote], cmdlen + 1 - wrote, L"\"%S%S\" ", wpath,
arg_lastchar == L'\\' ? L"\\" : L"");
arg_lastchar == L'\\' ? L"\\" : L"");
+ }
else
{
if (wcschr (arg, L' ') != NULL)
else
{
if (wcschr (arg, L' ') != NULL)
-
idx += swprintf (idx, L"\"%s%s\"%s
", arg,
+
wrote += swprintf (&wcmd[wrote], cmdlen + 1 - wrote, L"\"%S%S\"%S
", arg,
arg_lastchar == L'\\' ? L"\\" : L"", i == wargc ? L"" : L" ");
else
arg_lastchar == L'\\' ? L"\\" : L"", i == wargc ? L"" : L" ");
else
-
idx += swprintf (idx, L"%s%s%s
", arg,
+
wrote += swprintf (&wcmd[wrote], cmdlen + 1 - wrote, L"%S%S%S
", arg,
arg_lastchar == L'\\' ? L"\\" : L"", i == wargc ? L"" : L" ");
}
}
arg_lastchar == L'\\' ? L"\\" : L"", i == wargc ? L"" : L" ");
}
}
@@
-153,7
+156,7
@@
main (int argc, char *argv[])
if (!CreateProcessW (wpath, wcmd, NULL, NULL, TRUE, CREATE_SUSPENDED,
NULL, NULL, &start, &proc))
{
if (!CreateProcessW (wpath, wcmd, NULL, NULL, TRUE, CREATE_SUSPENDED,
NULL, NULL, &start, &proc))
{
- wprintf (L"Failed to get spawn process `%
s' with arguments `%s
': %lu\n", wpath, wcmd, GetLastError ());
+ wprintf (L"Failed to get spawn process `%
S' with arguments `%S
': %lu\n", wpath, wcmd, GetLastError ());
exit (6);
}
exit (6);
}
@@
-173,14
+176,16
@@
main (int argc, char *argv[])
if (wait_result != 0)
{
printf ("Test process exited with result %lu\n", status);
if (wait_result != 0)
{
printf ("Test process exited with result %lu\n", status);
+ TerminateJobObject (job, status);
exit (status);
}
printf ("Test process exited (failed to obtain exit status)\n");
exit (status);
}
printf ("Test process exited (failed to obtain exit status)\n");
+ TerminateJobObject (job, 0);
exit (0);
}
printf ("Child processes were killed after timeout of %u seconds\n",
timeout);
exit (0);
}
printf ("Child processes were killed after timeout of %u seconds\n",
timeout);
- TerminateJobObject (job,
0
);
+ TerminateJobObject (job,
1
);
CloseHandle (proc.hProcess);
exit (1);
}
CloseHandle (proc.hProcess);
exit (1);
}