mirror of https://github.com/aria2/aria2
Added fork() emulation using CreateProcess() in MinGW
parent
740a5aa51b
commit
e69889803a
|
@ -1,3 +1,8 @@
|
|||
2009-06-01 Ross Smith II <aria2spam at smithii dot com>
|
||||
|
||||
Added fork() emulation using CreateProcess() in MinGW
|
||||
* src/RequestGroupMan.cc
|
||||
|
||||
2009-06-01 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
||||
|
||||
* Release 1.4.0
|
||||
|
|
|
@ -197,6 +197,7 @@ static void executeHook(const std::string& command, int gid)
|
|||
{
|
||||
LogFactory::getInstance()->info("Executing user command: %s %d",
|
||||
command.c_str(), gid);
|
||||
#ifndef __MINGW32__
|
||||
pid_t cpid = fork();
|
||||
if(cpid == -1) {
|
||||
LogFactory::getInstance()->error("fork() failed."
|
||||
|
@ -206,6 +207,33 @@ static void executeHook(const std::string& command, int gid)
|
|||
perror(("Could not execute user command: "+command).c_str());
|
||||
_exit(1);
|
||||
}
|
||||
#else
|
||||
PROCESS_INFORMATION pi;
|
||||
STARTUPINFO si;
|
||||
|
||||
memset(&si, 0, sizeof (si));
|
||||
si.cb = sizeof(STARTUPINFO);
|
||||
|
||||
memset(&pi, 0, sizeof (pi));
|
||||
|
||||
std::string cmdline = command + " " + Util::itos(gid);
|
||||
|
||||
DWORD rc = CreateProcess(
|
||||
NULL,
|
||||
(LPSTR)cmdline.c_str(),
|
||||
NULL,
|
||||
NULL,
|
||||
true,
|
||||
NULL,
|
||||
NULL,
|
||||
0,
|
||||
&si,
|
||||
&pi);
|
||||
|
||||
if(!rc)
|
||||
LogFactory::getInstance()->error("CreateProcess() failed."
|
||||
" Cannot execute user command.");
|
||||
#endif
|
||||
}
|
||||
|
||||
static void executeStartHook
|
||||
|
|
Loading…
Reference in New Issue