<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[process handling unter windows]]></title><description><![CDATA[<p>Hallo,</p>
<p>es ist zwar C code, aber ich nehme mal an, das ihn einige hier verstehen<br />
können.<br />
Ich kenne mich nicht 100% mit windows API aus. das konnte ich<br />
nur so mit hilfe von internet und der ms hompage pasteln.</p>
<p>eigentlich sollte es funktionieren.<br />
aber ich bekomme nichts in die pipe geschickt.<br />
das programm wird sonst sauber ausgeführt.</p>
<p>es ist eine art popen unter windows.<br />
da popen bei mir eine konsole öffnete, und das bei einer GUI<br />
nicht besonders schön ist, habe ich mich entschlossen<br />
es selber zu inplementieren. soweit geht es,<br />
bis eben, das es keine pipe ausgabe macht.</p>
<pre><code class="language-cpp">extern &quot;C&quot; {
#include &lt;cstdio&gt;
#include &lt;signal.h&gt;
#include &lt;unistd.h&gt;

  //define
  int popen_pid;

#ifdef __WIN32__
#include &lt;windows.h&gt;
#include &lt;fcntl.h&gt;
#include &lt;io.h&gt;
#include &lt;stdlib.h&gt;

  HANDLE my_pipein[2], my_pipeout[2], my_pipeerr[2];
  char my_popenmode;

  static int my_pipe(HANDLE *readwrite){
    SECURITY_ATTRIBUTES sa;

    sa.nLength = sizeof(sa);          /* Laenge in Byte */
    sa.bInheritHandle = 1;            /* Descriptoren sollen vererbbar sein */
    sa.lpSecurityDescriptor = NULL;

    if (! CreatePipe (&amp;readwrite[0],&amp;readwrite[1],&amp;sa,1 &lt;&lt; 13)){
      errno = EMFILE;
      return -1;
    }

    return 0;
}

  FILE * pt_popen(const char *cmd, const char mode){

    FILE *fptr = (FILE *)0;
    PROCESS_INFORMATION piProcInfo;
    STARTUPINFO siStartInfo;

    my_pipein[0]   = INVALID_HANDLE_VALUE;
    my_pipein[1]   = INVALID_HANDLE_VALUE;
    my_pipeout[0]  = INVALID_HANDLE_VALUE;
    my_pipeout[1]  = INVALID_HANDLE_VALUE;
    my_pipeerr[0]  = INVALID_HANDLE_VALUE;
    my_pipeerr[1]  = INVALID_HANDLE_VALUE;

    my_popenmode = mode;
    if (my_popenmode != 'r' &amp;&amp; my_popenmode != 'w') return NULL;

   /* Erzeuge die Pipes... */
    if (my_pipe(my_pipein)  == -1 || my_pipe(my_pipeout) == -1) return NULL;

    /*
     * Erzeuge jetzt den Sohnprozess */
    ZeroMemory(&amp;siStartInfo, sizeof(STARTUPINFO));
    siStartInfo.cb           = sizeof(STARTUPINFO);
    siStartInfo.hStdInput    = my_pipein[0];
    siStartInfo.hStdOutput   = my_pipeout[1];
    siStartInfo.hStdError  = my_pipeerr[1];
    siStartInfo.dwFlags    = STARTF_USESTDHANDLES;

    popen_pid = CreateProcess(NULL,
			      (LPTSTR)cmd,       // command line 
			      NULL,              // process security attributes 
			      NULL,              // primary thread security attributes 
			      TRUE,              // handles are inherited 
			      DETACHED_PROCESS,  // creation flags: Ohne Fenster (?)
			      NULL,              // use parent's environment 
			      NULL,              // use parent's current directory 
			      &amp;siStartInfo,      // STARTUPINFO pointer 
			      &amp;piProcInfo);      // receives PROCESS_INFORMATION 

    if (!popen_pid) return NULL;

    /*
     * Diese Handles gehoeren dem Sohnprozess */
    CloseHandle(my_pipein[0]);  my_pipein[0]  = INVALID_HANDLE_VALUE;
    CloseHandle(my_pipeout[1]); my_pipeout[1] = INVALID_HANDLE_VALUE;
    CloseHandle(my_pipeerr[1]); my_pipeerr[1] = INVALID_HANDLE_VALUE;

    if(my_popenmode == 'r'){
      fptr = _fdopen(_open_osfhandle((long)my_pipeout[0], _O_BINARY),&quot;r&quot;);
    }else{
      fptr = _fdopen(_open_osfhandle((long)my_pipein[1], _O_BINARY),&quot;w&quot;);
    }
    if(!fptr){
      if(my_pipein[0]  != INVALID_HANDLE_VALUE)
	CloseHandle(my_pipein[0]);
      if(my_pipein[1]  != INVALID_HANDLE_VALUE)
	CloseHandle(my_pipein[1]);
      if(my_pipeout[0] != INVALID_HANDLE_VALUE)
	CloseHandle(my_pipeout[0]);
      if(my_pipeout[1] != INVALID_HANDLE_VALUE)
	CloseHandle(my_pipeout[1]);
      if(my_pipeerr[0] != INVALID_HANDLE_VALUE)
	CloseHandle(my_pipeerr[0]);
      if(my_pipeerr[1] != INVALID_HANDLE_VALUE)
	CloseHandle(my_pipeerr[1]);
    }
    return fptr;
  }

  int pt_pclose(FILE *fle){
    if (fle){
      (void)fclose(fle);

      CloseHandle(my_pipeerr[0]);
      if (my_popenmode == 'r')
	CloseHandle(my_pipein[1]);
      else
	CloseHandle(my_pipeout[0]);
      return 0;
    }
    return -1;
  }

  void pt_kill(void){
    TerminateProcess((void *)popen_pid, PROCESS_TERMINATE);
}

#else // Windows end
</code></pre>
<p>für tipps, kritick und inputs danek ich.</p>
<p>pascal</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/135719/process-handling-unter-windows</link><generator>RSS for Node</generator><lastBuildDate>Sun, 12 Jul 2026 04:43:51 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/135719.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 04 Feb 2006 14:03:08 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to process handling unter windows on Sat, 04 Feb 2006 14:03:08 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>es ist zwar C code, aber ich nehme mal an, das ihn einige hier verstehen<br />
können.<br />
Ich kenne mich nicht 100% mit windows API aus. das konnte ich<br />
nur so mit hilfe von internet und der ms hompage pasteln.</p>
<p>eigentlich sollte es funktionieren.<br />
aber ich bekomme nichts in die pipe geschickt.<br />
das programm wird sonst sauber ausgeführt.</p>
<p>es ist eine art popen unter windows.<br />
da popen bei mir eine konsole öffnete, und das bei einer GUI<br />
nicht besonders schön ist, habe ich mich entschlossen<br />
es selber zu inplementieren. soweit geht es,<br />
bis eben, das es keine pipe ausgabe macht.</p>
<pre><code class="language-cpp">extern &quot;C&quot; {
#include &lt;cstdio&gt;
#include &lt;signal.h&gt;
#include &lt;unistd.h&gt;

  //define
  int popen_pid;

#ifdef __WIN32__
#include &lt;windows.h&gt;
#include &lt;fcntl.h&gt;
#include &lt;io.h&gt;
#include &lt;stdlib.h&gt;

  HANDLE my_pipein[2], my_pipeout[2], my_pipeerr[2];
  char my_popenmode;

  static int my_pipe(HANDLE *readwrite){
    SECURITY_ATTRIBUTES sa;

    sa.nLength = sizeof(sa);          /* Laenge in Byte */
    sa.bInheritHandle = 1;            /* Descriptoren sollen vererbbar sein */
    sa.lpSecurityDescriptor = NULL;

    if (! CreatePipe (&amp;readwrite[0],&amp;readwrite[1],&amp;sa,1 &lt;&lt; 13)){
      errno = EMFILE;
      return -1;
    }

    return 0;
}

  FILE * pt_popen(const char *cmd, const char mode){

    FILE *fptr = (FILE *)0;
    PROCESS_INFORMATION piProcInfo;
    STARTUPINFO siStartInfo;

    my_pipein[0]   = INVALID_HANDLE_VALUE;
    my_pipein[1]   = INVALID_HANDLE_VALUE;
    my_pipeout[0]  = INVALID_HANDLE_VALUE;
    my_pipeout[1]  = INVALID_HANDLE_VALUE;
    my_pipeerr[0]  = INVALID_HANDLE_VALUE;
    my_pipeerr[1]  = INVALID_HANDLE_VALUE;

    my_popenmode = mode;
    if (my_popenmode != 'r' &amp;&amp; my_popenmode != 'w') return NULL;

   /* Erzeuge die Pipes... */
    if (my_pipe(my_pipein)  == -1 || my_pipe(my_pipeout) == -1) return NULL;

    /*
     * Erzeuge jetzt den Sohnprozess */
    ZeroMemory(&amp;siStartInfo, sizeof(STARTUPINFO));
    siStartInfo.cb           = sizeof(STARTUPINFO);
    siStartInfo.hStdInput    = my_pipein[0];
    siStartInfo.hStdOutput   = my_pipeout[1];
    siStartInfo.hStdError  = my_pipeerr[1];
    siStartInfo.dwFlags    = STARTF_USESTDHANDLES;

    popen_pid = CreateProcess(NULL,
			      (LPTSTR)cmd,       // command line 
			      NULL,              // process security attributes 
			      NULL,              // primary thread security attributes 
			      TRUE,              // handles are inherited 
			      DETACHED_PROCESS,  // creation flags: Ohne Fenster (?)
			      NULL,              // use parent's environment 
			      NULL,              // use parent's current directory 
			      &amp;siStartInfo,      // STARTUPINFO pointer 
			      &amp;piProcInfo);      // receives PROCESS_INFORMATION 

    if (!popen_pid) return NULL;

    /*
     * Diese Handles gehoeren dem Sohnprozess */
    CloseHandle(my_pipein[0]);  my_pipein[0]  = INVALID_HANDLE_VALUE;
    CloseHandle(my_pipeout[1]); my_pipeout[1] = INVALID_HANDLE_VALUE;
    CloseHandle(my_pipeerr[1]); my_pipeerr[1] = INVALID_HANDLE_VALUE;

    if(my_popenmode == 'r'){
      fptr = _fdopen(_open_osfhandle((long)my_pipeout[0], _O_BINARY),&quot;r&quot;);
    }else{
      fptr = _fdopen(_open_osfhandle((long)my_pipein[1], _O_BINARY),&quot;w&quot;);
    }
    if(!fptr){
      if(my_pipein[0]  != INVALID_HANDLE_VALUE)
	CloseHandle(my_pipein[0]);
      if(my_pipein[1]  != INVALID_HANDLE_VALUE)
	CloseHandle(my_pipein[1]);
      if(my_pipeout[0] != INVALID_HANDLE_VALUE)
	CloseHandle(my_pipeout[0]);
      if(my_pipeout[1] != INVALID_HANDLE_VALUE)
	CloseHandle(my_pipeout[1]);
      if(my_pipeerr[0] != INVALID_HANDLE_VALUE)
	CloseHandle(my_pipeerr[0]);
      if(my_pipeerr[1] != INVALID_HANDLE_VALUE)
	CloseHandle(my_pipeerr[1]);
    }
    return fptr;
  }

  int pt_pclose(FILE *fle){
    if (fle){
      (void)fclose(fle);

      CloseHandle(my_pipeerr[0]);
      if (my_popenmode == 'r')
	CloseHandle(my_pipein[1]);
      else
	CloseHandle(my_pipeout[0]);
      return 0;
    }
    return -1;
  }

  void pt_kill(void){
    TerminateProcess((void *)popen_pid, PROCESS_TERMINATE);
}

#else // Windows end
</code></pre>
<p>für tipps, kritick und inputs danek ich.</p>
<p>pascal</p>
]]></description><link>https://www.c-plusplus.net/forum/post/985670</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/985670</guid><dc:creator><![CDATA[xghost33]]></dc:creator><pubDate>Sat, 04 Feb 2006 14:03:08 GMT</pubDate></item><item><title><![CDATA[Reply to process handling unter windows on Sat, 04 Feb 2006 14:33:14 GMT]]></title><description><![CDATA[<p>was ist popen?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/985713</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/985713</guid><dc:creator><![CDATA[Vertexwahn]]></dc:creator><pubDate>Sat, 04 Feb 2006 14:33:14 GMT</pubDate></item><item><title><![CDATA[Reply to process handling unter windows on Sat, 04 Feb 2006 14:51:52 GMT]]></title><description><![CDATA[<p>popen öffnet einen process und gibt eine pipe zurück.<br />
du hast die wahl zwischen 'r' und 'w'</p>
<p>du kannst dann die pipe wie ein FILE * objekt handhaben.<br />
nur das es halt eine pipe (verbindung) zu einem anderen<br />
process ist.</p>
<p>sollte so etwa stimmen...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/985741</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/985741</guid><dc:creator><![CDATA[xghost33]]></dc:creator><pubDate>Sat, 04 Feb 2006 14:51:52 GMT</pubDate></item><item><title><![CDATA[Reply to process handling unter windows on Sat, 04 Feb 2006 16:48:34 GMT]]></title><description><![CDATA[<p>Dieser Thread wurde von Moderator/in <a href="http://www.c-plusplus.net/forum/profile.php?mode=viewprofile&amp;u=403" rel="nofollow">HumeSikkins</a> aus dem Forum <a href="http://www.c-plusplus.net/forum/viewforum.php?f=15" rel="nofollow">C++</a> in das Forum <a href="http://www.c-plusplus.net/forum/viewforum.php?f=4" rel="nofollow">WinAPI</a> verschoben.</p>
<p>Im Zweifelsfall bitte auch folgende Hinweise beachten:<br />
<a href="http://www.c-plusplus.net/forum/viewtopic.php?t=39405" rel="nofollow">C/C++ Forum :: FAQ - Sonstiges :: Wohin mit meiner Frage?</a></p>
<p><em>Dieses Posting wurde automatisch erzeugt.</em></p>
]]></description><link>https://www.c-plusplus.net/forum/post/985876</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/985876</guid><dc:creator><![CDATA[C++ Forumbot]]></dc:creator><pubDate>Sat, 04 Feb 2006 16:48:34 GMT</pubDate></item><item><title><![CDATA[Reply to process handling unter windows on Sat, 04 Feb 2006 16:53:45 GMT]]></title><description><![CDATA[<p>Siehe: <a href="http://support.microsoft.com/default.aspx?scid=kb;en-us;190351" rel="nofollow">http://support.microsoft.com/default.aspx?scid=kb;en-us;190351</a></p>
]]></description><link>https://www.c-plusplus.net/forum/post/985884</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/985884</guid><dc:creator><![CDATA[Jochen Kalmbach]]></dc:creator><pubDate>Sat, 04 Feb 2006 16:53:45 GMT</pubDate></item><item><title><![CDATA[Reply to process handling unter windows on Sun, 05 Feb 2006 10:06:29 GMT]]></title><description><![CDATA[<p>Jochen Kalmbach schrieb:</p>
<blockquote>
<p>Siehe: <a href="http://support.microsoft.com/default.aspx?scid=kb;en-us;190351" rel="nofollow">http://support.microsoft.com/default.aspx?scid=kb;en-us;190351</a></p>
</blockquote>
<p>dann meinst du, das ich die Handle falsch mache?</p>
<p>Ich nehme noch die arry in den handles raus.<br />
wieso ich die gemacht habe weiss ich wohl auch ned.</p>
<p>gg</p>
]]></description><link>https://www.c-plusplus.net/forum/post/986251</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/986251</guid><dc:creator><![CDATA[xGhost33]]></dc:creator><pubDate>Sun, 05 Feb 2006 10:06:29 GMT</pubDate></item><item><title><![CDATA[Reply to process handling unter windows on Sun, 05 Feb 2006 21:42:04 GMT]]></title><description><![CDATA[<p><img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f615.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--confused_face"
      title=":confused:"
      alt="😕"
    /> irgendwie schnalle ich es nicht so ganz...</p>
<p>das popen auf meiner unix nachzubilden war einfacher.<br />
wieso muss man nur alles komplizierter machen???</p>
<p>hat mir jemand einen kleinen tipp, in welche richtung ich suchen sollte?<br />
kann auch nur ein hinweis sein.</p>
<p>Danke,<br />
ghost</p>
]]></description><link>https://www.c-plusplus.net/forum/post/986947</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/986947</guid><dc:creator><![CDATA[xGhost]]></dc:creator><pubDate>Sun, 05 Feb 2006 21:42:04 GMT</pubDate></item><item><title><![CDATA[Reply to process handling unter windows on Sun, 05 Feb 2006 22:33:23 GMT]]></title><description><![CDATA[<p>Ich frage mich, warum Du etwas nachbilden willst was es schon lange gibt:<br />
<a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclib/html/_crt__popen.2c_._wpopen.asp" rel="nofollow">http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclib/html/_crt__popen.2c_._wpopen.asp</a></p>
<p>Und wenn Du wissen willst wie es gemacht wurde, dann schau einfach in den mitgelieferten Source oder debugge rein!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/986978</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/986978</guid><dc:creator><![CDATA[Jochen Kalmbach]]></dc:creator><pubDate>Sun, 05 Feb 2006 22:33:23 GMT</pubDate></item><item><title><![CDATA[Reply to process handling unter windows on Sun, 05 Feb 2006 22:56:09 GMT]]></title><description><![CDATA[<p>Jochen Kalmbach schrieb:</p>
<blockquote>
<p>Ich frage mich, warum Du etwas nachbilden willst was es schon lange gibt:<br />
<a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclib/html/_crt__popen.2c_._wpopen.asp" rel="nofollow">http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclib/html/_crt__popen.2c_._wpopen.asp</a></p>
<p>Und wenn Du wissen willst wie es gemacht wurde, dann schau einfach in den mitgelieferten Source oder debugge rein!</p>
</blockquote>
<p>jo, die frage ist berechtigt.</p>
<p>also:<br />
ich schreibe ein programm. es sollte auch unter windows laufen.<br />
(man will sie ja nicht benachteiligen) aber ich muss die<br />
pid haben. also bilde ich sie auf unix via fork() und execl() ab.<br />
funct super. so kann ich dann via kill() und anderem ...</p>
<p>nun will ich es aber auf windows genau so machen, so kann ich es via<br />
pt_popen() und pt_close() oder pt_kill() handhaben.<br />
und muss nur mein popen.cpp anpassen. bzw #if... __WIN32__</p>
<p>ich hab leider keinen gdb auf der windose, darum kann ich ned debugen<br />
*durchdreh*</p>
<p>gg</p>
]]></description><link>https://www.c-plusplus.net/forum/post/986989</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/986989</guid><dc:creator><![CDATA[xGhost]]></dc:creator><pubDate>Sun, 05 Feb 2006 22:56:09 GMT</pubDate></item><item><title><![CDATA[Reply to process handling unter windows on Mon, 06 Feb 2006 17:38:21 GMT]]></title><description><![CDATA[<p>durchsuche gerade die sourcen von mingw.</p>
<p>wie kann man unter windows debugen?</p>
<p>//edit<br />
im mingw hab ich nix gefunden...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/987773</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/987773</guid><dc:creator><![CDATA[xGhost]]></dc:creator><pubDate>Mon, 06 Feb 2006 17:38:21 GMT</pubDate></item><item><title><![CDATA[Reply to process handling unter windows on Mon, 06 Feb 2006 18:08:58 GMT]]></title><description><![CDATA[<p>xGhost schrieb:</p>
<blockquote>
<p>wie kann man unter windows debugen?</p>
</blockquote>
<p>Im VS F11 drücken !?</p>
<p>Du kannst auch das kostenlose VS 2005 Express runterladen:<br />
<a href="http://www.c-plusplus.net/forum/viewtopic-var-t-is-130812.html" rel="nofollow">http://www.c-plusplus.net/forum/viewtopic-var-t-is-130812.html</a></p>
]]></description><link>https://www.c-plusplus.net/forum/post/987809</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/987809</guid><dc:creator><![CDATA[Jochen Kalmbach]]></dc:creator><pubDate>Mon, 06 Feb 2006 18:08:58 GMT</pubDate></item><item><title><![CDATA[Reply to process handling unter windows on Mon, 06 Feb 2006 18:50:31 GMT]]></title><description><![CDATA[<p>hmm... danke.<br />
kannst du mir vl. noch einen tipp geben,<br />
wie ich dann (wenn ich ne windose aufgetrieben habe)<br />
die source heraus &quot;kopieren&quot; kann?<br />
ich hab einen debuger bis jetzt fuer anderes gebraucht <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /></p>
<p>danke,<br />
ghost</p>
]]></description><link>https://www.c-plusplus.net/forum/post/987867</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/987867</guid><dc:creator><![CDATA[xGhost]]></dc:creator><pubDate>Mon, 06 Feb 2006 18:50:31 GMT</pubDate></item><item><title><![CDATA[Reply to process handling unter windows on Mon, 06 Feb 2006 19:17:09 GMT]]></title><description><![CDATA[<p>xGhost schrieb:</p>
<blockquote>
<p>wie ich dann (wenn ich ne windose aufgetrieben habe)<br />
die source heraus &quot;kopieren&quot; kann?</p>
</blockquote>
<p>Verstehe ich nicht ganz... <em>Kopieren</em> darfst Du prinzipiell nix, da der Source Du ja nicht das Recht an dem Source hast...<br />
PS: VC++ Express 2005 ist in der aktuellen c´t kostenlos dabei...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/987909</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/987909</guid><dc:creator><![CDATA[Jochen Kalmbach]]></dc:creator><pubDate>Mon, 06 Feb 2006 19:17:09 GMT</pubDate></item><item><title><![CDATA[Reply to process handling unter windows on Mon, 06 Feb 2006 19:23:23 GMT]]></title><description><![CDATA[<p>ich will es auch nicht kopieren.<br />
ich will es nur vergleichen.</p>
<p>das problem, popen:<br />
ich habe keine pid.<br />
es wird in einer konsole geoeffnet, die aber lehr bleibt.</p>
<p>also muss ich es wohl selbst integrieren,<br />
und die noetigen parameter aendern.</p>
<p>das programm ist opensource, so wie alles was ich mache.</p>
<p>gg</p>
]]></description><link>https://www.c-plusplus.net/forum/post/987921</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/987921</guid><dc:creator><![CDATA[xGhost]]></dc:creator><pubDate>Mon, 06 Feb 2006 19:23:23 GMT</pubDate></item><item><title><![CDATA[Reply to process handling unter windows on Mon, 06 Feb 2006 21:08:33 GMT]]></title><description><![CDATA[<p><img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f62e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--face_with_open_mouth"
      title=":open_mouth:"
      alt="😮"
    /> das man mit dieser klicker *** arbeiten kann *respekt*<br />
ich bleibe lieber beim evektiven coden im emacs.</p>
<p>muss es wohl anders versuchen.<br />
danke trotzdem für eure hilfe.</p>
<p>gg</p>
]]></description><link>https://www.c-plusplus.net/forum/post/988099</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/988099</guid><dc:creator><![CDATA[xghost_auf_winschrott]]></dc:creator><pubDate>Mon, 06 Feb 2006 21:08:33 GMT</pubDate></item><item><title><![CDATA[Reply to process handling unter windows on Mon, 06 Feb 2006 21:12:48 GMT]]></title><description><![CDATA[<p>gehts noch?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/988103</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/988103</guid><dc:creator><![CDATA[dumm?]]></dc:creator><pubDate>Mon, 06 Feb 2006 21:12:48 GMT</pubDate></item><item><title><![CDATA[Reply to process handling unter windows on Mon, 06 Feb 2006 22:11:07 GMT]]></title><description><![CDATA[<p>jo, glaube schon.</p>
<p>fuer mich ist dieses rumgeklicke einfach kein leben.</p>
<p>leider sind die sourcen unter windows not open.<br />
naja. mal weiter schauen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/988119</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/988119</guid><dc:creator><![CDATA[xGhost]]></dc:creator><pubDate>Mon, 06 Feb 2006 22:11:07 GMT</pubDate></item><item><title><![CDATA[Reply to process handling unter windows on Tue, 07 Feb 2006 09:39:10 GMT]]></title><description><![CDATA[<p>versuche es mal so...</p>
<pre><code class="language-cpp">extern &quot;C&quot; {
#include &lt;cstdio&gt;
#include &lt;signal.h&gt;
#include &lt;unistd.h&gt;

  //define
  int popen_pid;

#ifdef __WIN32__
#include &lt;windows.h&gt;
#include &lt;fcntl.h&gt;
#include &lt;io.h&gt;
#include &lt;stdlib.h&gt;

  HANDLE my_pipein, my_pipeout, my_pipeerr;
  char my_popenmode;

  static int my_pipe(HANDLE *readwrite){
    SECURITY_ATTRIBUTES sa;

    sa.nLength = sizeof(sa);          /* Laenge in Byte */
    sa.bInheritHandle = 1;            /* Descriptoren sollen vererbbar sein */
    sa.lpSecurityDescriptor = NULL;

    if (! CreatePipe (&amp;readwrite,&amp;readwrite,&amp;sa,1 &lt;&lt; 13)){
      errno = EMFILE;
      return -1;
    }

    return 0;
}

  FILE * pt_popen(const char *cmd, const char mode){

    FILE *fptr = (FILE *)0;
    PROCESS_INFORMATION piProcInfo;
    STARTUPINFO siStartInfo;

    my_pipein   = GetStdHandle(STD_INPUT_HANDLE);
    my_pipeout  = GetStdHandle(STD_OUTPUT_HANDLE);

    my_popenmode = mode;
    if (my_popenmode != 'r' &amp;&amp; my_popenmode != 'w') return NULL;

   /* Erzeuge die Pipes... */
    if (my_pipe(my_pipein)  == -1 || my_pipe(my_pipeout) == -1) return NULL;

    /*
     * Erzeuge jetzt den Sohnprozess */
    ZeroMemory(&amp;siStartInfo, sizeof(STARTUPINFO));
    siStartInfo.cb           = sizeof(STARTUPINFO);
    siStartInfo.hStdInput    = my_pipein;
    siStartInfo.hStdOutput   = my_pipeout;
    siStartInfo.hStdError  = my_pipeout;
    siStartInfo.dwFlags    = STARTF_USESTDHANDLES;

    popen_pid = CreateProcess(NULL,
                  (LPTSTR)cmd,       // command line
                  NULL,              // process security attributes
                  NULL,              // primary thread security attributes
                  TRUE,              // handles are inherited
                  DETACHED_PROCESS,  // creation flags: Ohne Fenster (?)
                  NULL,              // use parent's environment
                  NULL,              // use parent's current directory
                  &amp;siStartInfo,      // STARTUPINFO pointer
                  &amp;piProcInfo);      // receives PROCESS_INFORMATION

    if (!popen_pid) return NULL;

    /*
     * Diese Handles gehoeren dem Sohnprozess */
    CloseHandle(my_pipein);  my_pipein   = GetStdHandle(STD_INPUT_HANDLE);
    CloseHandle(my_pipeout); my_pipeout = GetStdHandle(STD_OUTPUT_HANDLE);

    if(my_popenmode == 'r'){
      fptr = _fdopen(_open_osfhandle((long)my_pipeout, _O_BINARY),&quot;r&quot;);
    }else{
      fptr = _fdopen(_open_osfhandle((long)my_pipein, _O_BINARY),&quot;w&quot;);
    }
    if(!fptr){
      if(my_pipein  != INVALID_HANDLE_VALUE)
    CloseHandle(my_pipein);
      if(my_pipein  != INVALID_HANDLE_VALUE)
    CloseHandle(my_pipeout[0]);
      if(my_pipeout != INVALID_HANDLE_VALUE)
    }
    return fptr;
  }

  int pt_pclose(FILE *fle){
    if (fle){
      (void)fclose(fle);

      if (my_popenmode == 'r')
    CloseHandle(my_pipein);
      else
    CloseHandle(my_pipeout);
      return 0;
    }
    return -1;
  }

  void pt_kill(void){
    TerminateProcess((void *)popen_pid, PROCESS_TERMINATE);
}

#else // Windows end
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/988284</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/988284</guid><dc:creator><![CDATA[numpar]]></dc:creator><pubDate>Tue, 07 Feb 2006 09:39:10 GMT</pubDate></item><item><title><![CDATA[Reply to process handling unter windows on Tue, 07 Feb 2006 09:46:00 GMT]]></title><description><![CDATA[<p>Nur so als kleiner Hinweis:<br />
Das casten des zweiten Parameters von &quot;cmd&quot; (also const char*) nach &quot;LPTSTR&quot; ist falsch, da dies nicht mit Unicode geht. Und wenn Du es für Unicode hinbekommen würdest, würde es abstürzen:<br />
<a href="http://blog.kalmbachnet.de/?postid=62" rel="nofollow">http://blog.kalmbachnet.de/?postid=62</a></p>
]]></description><link>https://www.c-plusplus.net/forum/post/988292</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/988292</guid><dc:creator><![CDATA[Jochen Kalmbach]]></dc:creator><pubDate>Tue, 07 Feb 2006 09:46:00 GMT</pubDate></item><item><title><![CDATA[Reply to process handling unter windows on Tue, 07 Feb 2006 09:47:55 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">static int my_pipe(HANDLE *readwrite){
    SECURITY_ATTRIBUTES sa;

    sa.nLength = sizeof(sa);          /* Laenge in Byte */
    sa.bInheritHandle = 1;            /* Descriptoren sollen vererbbar sein */
    sa.lpSecurityDescriptor = NULL;

    if (! CreatePipe (&amp;readwrite,&amp;readwrite,&amp;sa,1 &lt;&lt; 13)){
      errno = EMFILE;
      return -1;
    }

    return 0;
}

  FILE * pt_popen(const char *cmd, const char mode){

    FILE *fptr = (FILE *)0;
    PROCESS_INFORMATION piProcInfo;
    STARTUPINFO siStartInfo;

    my_pipein   = GetStdHandle(STD_INPUT_HANDLE);
    my_pipeout  = GetStdHandle(STD_OUTPUT_HANDLE);

    my_popenmode = mode;
    if (my_popenmode != 'r' &amp;&amp; my_popenmode != 'w') return NULL;

   /* Erzeuge die Pipes... */
    if (my_pipe(my_pipein)  == -1 || my_pipe(my_pipeout) == -1) return NULL;
</code></pre>
<p>zu</p>
<pre><code class="language-cpp">static int my_pipe(HANDLE *read, HANDLE *write){
    SECURITY_ATTRIBUTES sa;
    sa.nLength = sizeof(sa);          /* Laenge in Byte */
    sa.bInheritHandle = 1;            /* Descriptoren sollen vererbbar sein */
    sa.lpSecurityDescriptor = NULL;

    if (! CreatePipe (&amp;read,&amp;write,&amp;sa,1 &lt;&lt; 13)){
      errno = EMFILE;
      return -1;
    }

    return 0;
}

  FILE * pt_popen(const char *cmd, const char mode){

    FILE *fptr = (FILE *)0;
    PROCESS_INFORMATION piProcInfo;
    STARTUPINFO siStartInfo;

    my_pipein   = GetStdHandle(STD_INPUT_HANDLE);
    my_pipeout  = GetStdHandle(STD_OUTPUT_HANDLE);

    my_popenmode = mode;
    if (my_popenmode != 'r' &amp;&amp; my_popenmode != 'w') return NULL;

   /* Erzeuge die Pipes... */
    if (my_pipe(my_pipeout, my_pipein)  == -1) return NULL;
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/988294</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/988294</guid><dc:creator><![CDATA[numpar]]></dc:creator><pubDate>Tue, 07 Feb 2006 09:47:55 GMT</pubDate></item><item><title><![CDATA[Reply to process handling unter windows on Tue, 07 Feb 2006 09:51:24 GMT]]></title><description><![CDATA[<p>Jochen Kalmbach schrieb:</p>
<blockquote>
<p>Nur so als kleiner Hinweis:<br />
Das casten des zweiten Parameters von &quot;cmd&quot; (also const char*) nach &quot;LPTSTR&quot; ist falsch, da dies nicht mit Unicode geht. Und wenn Du es für Unicode hinbekommen würdest, würde es abstürzen:<br />
<a href="http://blog.kalmbachnet.de/?postid=62" rel="nofollow">http://blog.kalmbachnet.de/?postid=62</a></p>
</blockquote>
<p>gut, danke</p>
]]></description><link>https://www.c-plusplus.net/forum/post/988302</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/988302</guid><dc:creator><![CDATA[xGhost]]></dc:creator><pubDate>Tue, 07 Feb 2006 09:51:24 GMT</pubDate></item><item><title><![CDATA[Reply to process handling unter windows on Tue, 07 Feb 2006 10:34:47 GMT]]></title><description><![CDATA[<p><a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/creating_a_child_process_with_redirected_input_and_output.asp" rel="nofollow">http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/creating_a_child_process_with_redirected_input_and_output.asp</a></p>
]]></description><link>https://www.c-plusplus.net/forum/post/988333</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/988333</guid><dc:creator><![CDATA[xGhost]]></dc:creator><pubDate>Tue, 07 Feb 2006 10:34:47 GMT</pubDate></item></channel></rss>