Maximus5 / conemu-inside

An example, how to embed http://conemu.github.io/ into another graphical application
57 stars 42 forks source link

GuiMacro GetInfo Root Returns Status=Unknown on Startup #8

Closed hypersw closed 8 years ago

hypersw commented 8 years ago

Not critical, but strange from the API point of view. When this happens at the moment when payload process has not started yet inside conemu, then I hope conemu knows about this situation, I'd rather expect to see statuses change along the chain Loading->Running->Exited than get it Unknown.

Maximus5 commented 8 years ago

If there was no root started yet? Moreover, if there were no RealConsole yet? I consider "Loading" in incorrect. ConEmu may be started even with -detached switch.

hypersw commented 8 years ago

Does ConEmuCD itself know which case this is? If yes, it should better return the specific state (like, root not started, or not attached). Otherwise client has to guess this on the user side based on its own state machine and assumptions on what happens inside of ConEmu, which is error-prone. Visual Studio API is rich on such loose contracts, and it's always a headache. Aaah we could not tell you the value right now. Go guess why, maybe it's an error or you're simply calling too soon on solution load or we're just in the middle of processing a change.

Maximus5 commented 8 years ago

If shell is running, or terminated, macro returns smth like

<Root
        Name="git.exe"
        Running="true"
        PID="1234"
        ExitCode="259"
        UpTime="591594"
/>

What do you prefer to receive if shell was not started yet?

hypersw commented 8 years ago

Me, I can do with what there is right now. It's working in the control.

I'm thinking from the API point of view, and what a novice user of the API would see and understand. Currently, you might not be getting the Running attribute at all, there's no clear explanation what this means, the user has to guess that the root process has not started yet. It's nicer to put this explicitly, like returning the State="NotStarted", State="Running", State="Exited". Maybe there're more states, yet again, would be better if ConEmu says them as they are, because guesswork on user's part is always error-prone.

BTW got a question on attribute value types. You're calling itow for PID, but all the WinAPIs consider it a DWORD, so my guess was to parse it as an unsigned integer, but conemu src says otherwise: it's rendered as a signed int, though stored in pOut->RootInfo.nPID as a DWORD. Shouldn't it be ui…tow conversion, to match the type used in WinAPI? Same for the exit code, though it's not so unexpected for it to be signed. But this has to be specified in docs on GetInfo Root so that to know what to parse for. As PIDs are unlikely to be over 2G, for exit codes this is quite possible.

hypersw commented 8 years ago

Wow, github didn't notify me of this change (probably, as it's just a linked commit to the issue and not a comment). As a result, the control won't detect payload exit with fresh conemu until the emulator process exits. Updating…