|
From: Joerg B. <jo...@sq...> - 2002-08-23 12:23:54
|
Hi! Al Slater wrote: > > > Aside: A colleague just stumbled over the problem that even the > > function "popen" can not be used in Win-NT if the program is a > > "window" application, it is restricted to "console". > > > > are you saying the "client" app must be console, or the "target" app? She had this experience: - Some code calling "popen ( ... , rt )" worked in a test program, which she started from a DOS box. - This code failed when being part of a DLL used in a program which was started by a Web server. In your terms, this would probably be the "client" (= caller). My interpretation is that this calling program is no "console" application as it does not have "stdin / stdout / stderr", but this is a guess. (Explanations of "windows program" vs. "console program" are welcome, especially when including the handling of "services".) Regarding the "target": IMHO, the worst that can happen is that no data is read from / written to the pipe created by "popen()". I fail to see why this should be a problem, when the target terminates the pipe will be closed and any remaining data discarded. The restriction is documented in MSDN: | Note The _popen function returns an invalid file handle, | if used in a Windows program, that will cause the program | to hang indefinitely. _popen works properly in a Console | application. To create a Windows application that redirects | input and output, read the section "Creating a Child Process | with Redirected Input and Output" in the Win32 SDK. URL (one-liner!): http://msdn.microsoft.com/library/en-us/vccore98/HTML/_crt__popen.2c_._wpopen.asp What surprises me most is the expression "invalid file handle" - I would expect a NULL if something fails (like tested in the application example in that man page), but certainly not a "hang indefinitely". "Abandon all hope, ..." Regards, Joerg -- Joerg Bruehe, SQL Datenbanksysteme GmbH, Berlin, Germany (speaking only for himself) mailto: jo...@sq... |