When fork()/exec() fails do a exit(EXIT_FAILURE) instead of letting the fork() continue
This commit is contained in:
parent
6389c86df6
commit
92342cde0d
3 changed files with 19 additions and 15 deletions
1
NEWS
1
NEWS
|
@ -11,6 +11,7 @@ xboxdrv 0.6.3 - (10/Jan/2011)
|
|||
* fixed multiple bugs that made it impossible to assign events to
|
||||
specific devices
|
||||
* fixed axis getting stuck when using a shift key
|
||||
* fixed incorrect error handling on fork()/exec()
|
||||
|
||||
|
||||
xboxdrv 0.6.2 - (31/Dec/2010)
|
||||
|
|
|
@ -525,13 +525,8 @@ ExecButtonEventHandler::send(uInput& uinput, bool value)
|
|||
if (execvp(m_args[0].c_str(), argv) == -1)
|
||||
{
|
||||
std::cout << "error: ExecButtonEventHandler::send(): " << strerror(errno) << std::endl;
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
for(size_t i = 0; i < m_args.size(); ++i)
|
||||
{
|
||||
free(argv[i]);
|
||||
}
|
||||
free(argv);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -341,7 +341,7 @@ Xboxdrv::controller_loop(GamepadType type, uInput* uinput, XboxGenericController
|
|||
pid = fork();
|
||||
if (pid == 0)
|
||||
{
|
||||
char** argv = static_cast<char**>(malloc(sizeof(char*) * opts.exec.size()));
|
||||
char** argv = static_cast<char**>(malloc(sizeof(char*) * opts.exec.size() + 1));
|
||||
for(size_t i = 0; i < opts.exec.size(); ++i)
|
||||
{
|
||||
argv[i] = strdup(opts.exec[i].c_str());
|
||||
|
@ -351,13 +351,9 @@ Xboxdrv::controller_loop(GamepadType type, uInput* uinput, XboxGenericController
|
|||
if (execvp(opts.exec[0].c_str(), argv) == -1)
|
||||
{
|
||||
std::cout << "error: " << opts.exec[0] << ": " << strerror(errno) << std::endl;
|
||||
// FIXME: must signal the parent process
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
for(size_t i = 0; i < opts.exec.size(); ++i)
|
||||
{
|
||||
free(argv[i]);
|
||||
}
|
||||
free(argv);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -433,9 +429,21 @@ Xboxdrv::controller_loop(GamepadType type, uInput* uinput, XboxGenericController
|
|||
|
||||
if (w > 0)
|
||||
{
|
||||
if (WIFEXITED(status) || WIFSIGNALED(status))
|
||||
if (WIFEXITED(status))
|
||||
{
|
||||
std::cout << "Child program has stopped, shutting down xboxdrv" << std::endl;
|
||||
if (WEXITSTATUS(status) != 0)
|
||||
{
|
||||
std::cout << "error: child program has stopped with exit status " << WEXITSTATUS(status) << std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << "child program exited successful" << std::endl;
|
||||
}
|
||||
global_exit_xboxdrv = true;
|
||||
}
|
||||
else if (WIFSIGNALED(status))
|
||||
{
|
||||
std::cout << "error: child program was terminated by " << WTERMSIG(status) << std::endl;
|
||||
global_exit_xboxdrv = true;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue