{"id":6966,"date":"2014-05-16T01:14:37","date_gmt":"2014-05-16T01:14:37","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/05\/16\/processbuilder-without-redirecting-stdout-collection-of-common-programming-errors\/"},"modified":"2014-05-16T01:14:37","modified_gmt":"2014-05-16T01:14:37","slug":"processbuilder-without-redirecting-stdout-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/05\/16\/processbuilder-without-redirecting-stdout-collection-of-common-programming-errors\/","title":{"rendered":"Processbuilder without redirecting StdOut-Collection of common programming errors"},"content":{"rendered":"<p>I think you&#8217;re talking about making the launched process&#8217; stdout go to the current process&#8217; stdout. If you&#8217;re using JDK7, that&#8217;s as simple as:<\/p>\n<pre><code>.redirectOutput(ProcessBuilder.Redirect.INHERIT)\n<\/code><\/pre>\n<p><strong>Update:<\/strong> (too much for a comment) I think you&#8217;re confused. When you launch a process from a terminal, the process becomes a child of that terminal process, and the stdout is sent to that terminal. When you launch a process from Java, then the process is a child of the Java process, and its stdout goes to Java.<\/p>\n<p>In the first case, there&#8217;s a terminal showing stdout because you launched it from a terminal yourself, and that&#8217;s what terminals do with stdout. When launching from Java, however, there wouldn&#8217;t be a terminal window unless something in the process you launched opened a terminal, and stdout of the process you launched is handed back to you, the programmer, to do with as you will. The equivalent behavior to what you see when launching from a terminal is the <code>Redirect.INHERIT<\/code> that I already mentioned.<\/p>\n<p>Your problem right now isn&#8217;t Java. Your problem is not understanding how this &#8220;srcds.exe&#8221; expects stdin and stdout to be handled. Figure that out, and then come back and ask how to do that with Java.<\/p>\n<p>I&#8217;m just guessing now, but you could try reading from the process&#8217; stdout and feeding it back into the stdin. Maybe that&#8217;s what it&#8217;s expecting? That sounds crazy, though.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I think you&#8217;re talking about making the launched process&#8217; stdout go to the current process&#8217; stdout. If you&#8217;re using JDK7, that&#8217;s as simple as: .redirectOutput(ProcessBuilder.Redirect.INHERIT) Update: (too much for a comment) I think you&#8217;re confused. When you launch a process from a terminal, the process becomes a child of that terminal process, and the stdout [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-6966","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/6966","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=6966"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/6966\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=6966"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=6966"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=6966"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}