I've got a weird message
-
Sometimes when I run a console program I get this "Cannot obtain a handle to the inferior. The parameter is incorrect".
Yet my program runs okay. What in the world? Any way to stop that message?
-
please use the search before posting a question...
Read "this":http://qt-project.org/forums/viewthread/21311 thread. -
I read that and I used the Search before posting, just so you know. Appears that people are still having the issue.
-
maybe you can provide a bit more infos with your question next time so i could have known...
You also could have told us what you already tried so far ... -
Only thing I've tried so far has been to install version 5.1. I still get that message. I don't see an application folder, cuz I was going to try that fellow's suggestion as he talked about in that post.
-
I assume you mean Qt 5.1
Since you have not told us I am going to assume that you are using a recent Qt Creator on the Windows platform and that the message is displayed in the Application Output pane of Qt Creator when it is run.
The first part of message comes from Qt Creator, and the second "Parameter is invalid" from Windows. It is in response to this Windows API call:
@
// Qt Creator source: src/libs/utils/consoleprocess_win.cpp
// ConsoleProcess::readStubOutput()d->m_hInferior = OpenProcess( SYNCHRONIZE | PROCESS_QUERY_INFORMATION | PROCESS_TERMINATE, FALSE, d->m_appPid); if (d->m_hInferior == NULL) { emit processError(tr("Cannot obtain a handle to the inferior: %1") .arg(winErrorMessage(GetLastError()))); // Uhm, and now what? continue; }
@
The first two parameters have little leeway to be incorrect, leaving the third argument: the process id (PID) of the launched program. It strikes me that this will fail if the program, launched by the Qt Creator process stub on your behalf, has already run to completion and terminated. In that case the specified PID will not exist. Does your unspecified "console program" run through quickly to completion?
It would also fail if the Qt Creator process stub output no PID, or zero, after the "pid " introducer. This would indicate a failing CreateProcessW() call in src/libs/utils/process_stub_win.c of Qt Creator.
-
I build. I run. The program shows the DOS window output. Just like it's supposed to. But there is this warning in red ink in the application output pane.
-
Could you answer the question?
bq. Does your unspecified “console program” run through quickly to completion?
-
Yes. I noticed that I can run a program and the first time everything is fine with no warnings. If I choose to run the program again that message comes up. I've also tried using Qt with VS2012. Same message.
-
The message has nothing to do with your choice of Qt version or compiler for your project. The message is originating in Qt Creator when it is asked to run your program (which may have no Qt involvement at all).
Creator launches the executable using a stub launcher program that provides Creator with some information about the process launched. This stub returns the process id, and Creator tries to get a handle to that process so it can be notified when it terminates. If it cannot get a handle to the process then you get the warning; this may happen if the process id has already ceased to exist because the program exited quickly. It may be something else, I am just making an intelligent guess. Whether you could avoid this situation I don't know.
From what you are saying it runs your program successfully in spite of the warning. Unless you intend to debug the Qt Creator stub and handling code I suggest you simply ignore the warning.