<?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[Hintergrundprozess über SSH-Verbindung starten]]></title><description><![CDATA[<p>Hallo</p>
<p>ich möchte einen Prozess auf einem Windows-Sysem mit SSH starten. Die SSH-Verbindungen soll nach dem Start des Prozesses beendet werden, der Prozess (perl-Skript) soll aber weiterlaufen. Ich habe das mit folgendem Programm und der Funktion CreateProcess versucht. In der DOS-Box funktioniert das, auch wenn ich die DOS-Box schließe (DETACHED_PROCESS). Rufe ich das Programm remote über eine SSH-Verbindungen auf, wird das Perl-Skript angestartet und mit der Beendigung der SSH-Session abgebrochen. Ich vermute das durch die Beendigung der SSH-Session die komplette Prozessgruppe terminiert wird.</p>
<p>Ich bin kein Windows-Spezi, unter Unix/Linux funktionert so ein Kontstrukt (mit ein wenig forken). Das habe ich natürlich im Perl-Skript auch versucht - leider ohne Erfolg.</p>
<p>Gibts es unter Windows eine Möglichkeit einen Prozess von seiner Session zu trennen, so dass er bei der Beendigung der Session nicht automatisch abgebrochen wird. Das Setzen von CREATE_NEW_PROCESS_GROUP bewirkt das leider nicht.</p>
<p>(Das Perl-Skript ist kein Dauerläufer, so dass ein Windows-Dienst eigentlich nicht in Frage kommt.)</p>
<p>Wäre sehr froh, wenn jemand dazu eine Idee hätte ...</p>
<p>SSH-Server: WRQ-Reflection 6.1 Build 19<br />
SSH-Client Aufruf: ssh user@host CreateProcess.exe</p>
<pre><code class="language-cpp">void _tmain( int argc, _TCHAR* argv[] )
{
    STARTUPINFO si;
    PROCESS_INFORMATION pi;
    LPTSTR szCmdline=_tcsdup(TEXT(&quot;perl.exe test.pl 60&quot;));
    //LPTSTR szCmdline=_tcsdup(TEXT(argv[1]));

	signal (SIGINT,   SIG_IGN);
	signal (SIGTERM,  SIG_IGN);
	signal (SIGBREAK, SIG_IGN);
	signal (SIGABRT,  SIG_IGN);

    ZeroMemory( &amp;si, sizeof(si) );
    si.cb = sizeof(si);
    ZeroMemory( &amp;pi, sizeof(pi) );

    // Start the child process. 
    if( !CreateProcess(
	NULL,		// No module name (use command line)
        szCmdline,      // Command line
        NULL,           // Process handle not inheritable
        NULL,           // Thread handle not inheritable
        FALSE,          // Set handle inheritance to FALSE
        CREATE_NEW_PROCESS_GROUP | DETACHED_PROCESS,              // Creation flags
        NULL,           // Use parent's environment block
        NULL,           // Use parent's starting directory 
        &amp;si,            // Pointer to STARTUPINFO structure
        &amp;pi )           // Pointer to PROCESS_INFORMATION structure
    ) 
    {
        printf( &quot;CreateProcess failed (%d).\n&quot;, GetLastError() );
        return;
    }

    // Wait until child process exits.
    //WaitForSingleObject( pi.hProcess, INFINITE );
    WaitForInputIdle( pi.hProcess, INFINITE );

    // Close process and thread handles. 
    CloseHandle( pi.hProcess );
    CloseHandle( pi.hThread );
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/topic/169175/hintergrundprozess-über-ssh-verbindung-starten</link><generator>RSS for Node</generator><lastBuildDate>Wed, 15 Jul 2026 22:48:04 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/169175.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 02 Jan 2007 21:21:58 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Hintergrundprozess über SSH-Verbindung starten on Tue, 02 Jan 2007 21:21:58 GMT]]></title><description><![CDATA[<p>Hallo</p>
<p>ich möchte einen Prozess auf einem Windows-Sysem mit SSH starten. Die SSH-Verbindungen soll nach dem Start des Prozesses beendet werden, der Prozess (perl-Skript) soll aber weiterlaufen. Ich habe das mit folgendem Programm und der Funktion CreateProcess versucht. In der DOS-Box funktioniert das, auch wenn ich die DOS-Box schließe (DETACHED_PROCESS). Rufe ich das Programm remote über eine SSH-Verbindungen auf, wird das Perl-Skript angestartet und mit der Beendigung der SSH-Session abgebrochen. Ich vermute das durch die Beendigung der SSH-Session die komplette Prozessgruppe terminiert wird.</p>
<p>Ich bin kein Windows-Spezi, unter Unix/Linux funktionert so ein Kontstrukt (mit ein wenig forken). Das habe ich natürlich im Perl-Skript auch versucht - leider ohne Erfolg.</p>
<p>Gibts es unter Windows eine Möglichkeit einen Prozess von seiner Session zu trennen, so dass er bei der Beendigung der Session nicht automatisch abgebrochen wird. Das Setzen von CREATE_NEW_PROCESS_GROUP bewirkt das leider nicht.</p>
<p>(Das Perl-Skript ist kein Dauerläufer, so dass ein Windows-Dienst eigentlich nicht in Frage kommt.)</p>
<p>Wäre sehr froh, wenn jemand dazu eine Idee hätte ...</p>
<p>SSH-Server: WRQ-Reflection 6.1 Build 19<br />
SSH-Client Aufruf: ssh user@host CreateProcess.exe</p>
<pre><code class="language-cpp">void _tmain( int argc, _TCHAR* argv[] )
{
    STARTUPINFO si;
    PROCESS_INFORMATION pi;
    LPTSTR szCmdline=_tcsdup(TEXT(&quot;perl.exe test.pl 60&quot;));
    //LPTSTR szCmdline=_tcsdup(TEXT(argv[1]));

	signal (SIGINT,   SIG_IGN);
	signal (SIGTERM,  SIG_IGN);
	signal (SIGBREAK, SIG_IGN);
	signal (SIGABRT,  SIG_IGN);

    ZeroMemory( &amp;si, sizeof(si) );
    si.cb = sizeof(si);
    ZeroMemory( &amp;pi, sizeof(pi) );

    // Start the child process. 
    if( !CreateProcess(
	NULL,		// No module name (use command line)
        szCmdline,      // Command line
        NULL,           // Process handle not inheritable
        NULL,           // Thread handle not inheritable
        FALSE,          // Set handle inheritance to FALSE
        CREATE_NEW_PROCESS_GROUP | DETACHED_PROCESS,              // Creation flags
        NULL,           // Use parent's environment block
        NULL,           // Use parent's starting directory 
        &amp;si,            // Pointer to STARTUPINFO structure
        &amp;pi )           // Pointer to PROCESS_INFORMATION structure
    ) 
    {
        printf( &quot;CreateProcess failed (%d).\n&quot;, GetLastError() );
        return;
    }

    // Wait until child process exits.
    //WaitForSingleObject( pi.hProcess, INFINITE );
    WaitForInputIdle( pi.hProcess, INFINITE );

    // Close process and thread handles. 
    CloseHandle( pi.hProcess );
    CloseHandle( pi.hThread );
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1201475</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1201475</guid><dc:creator><![CDATA[razac]]></dc:creator><pubDate>Tue, 02 Jan 2007 21:21:58 GMT</pubDate></item></channel></rss>