Skip to content

Commit

Permalink
restarter quotes parameters with spaces (IDEA-63584)
Browse files Browse the repository at this point in the history
  • Loading branch information
yole committed Jan 20, 2011
1 parent d2b4f4e commit 42b6a7c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
Binary file modified bin/win/restarter.exe
Binary file not shown.
22 changes: 21 additions & 1 deletion native/restarter/restarter.cpp
Expand Up @@ -28,7 +28,27 @@ int _tmain(int argc, _TCHAR* argv[])
CloseHandle(parent_process);
}

int rc = _texecv(argv [2], argv+2);
int child_argc = argc-2;
_TCHAR** child_argv = new _TCHAR* [child_argc+1];
for(int i = 0; i < child_argc; i++)
{
if (_tcschr(argv[i+2], ' '))
{
int len = _tcslen(argv[i+2]) + 3;
TCHAR *arg = new TCHAR[len];
arg[0] = '\"';
_tcscpy_s(arg+1, len, argv[i+2]);
_tcscat_s(arg, len, _T("\""));
child_argv[i] = arg;
}
else
{
child_argv[i] = argv[i+2];
}
}
child_argv[child_argc] = '\0';

int rc = _texecv(argv [2], child_argv);
if (rc == -1)
{
_tprintf(_T("Error restarting process: errno is %d"), errno);
Expand Down

0 comments on commit 42b6a7c

Please sign in to comment.