digitalmars.D - _popen alternative in D?
- Maraco (21/21) Jul 21 2011 Hello.
- Vladimir Panteleev (11/32) Jul 21 2011 This functionality is currently not implemented in D's standard library.
- Maraco (2/2) Jul 21 2011 Ok so i need to wait until process will exit and read output from file
- Vladimir Panteleev (7/9) Jul 21 2011 Here's how I do it (warning: not very good D1 code):
- Maraco (1/1) Jul 21 2011 Thanks. I will try.
- Steven Schveighoffer (11/46) Jul 21 2011 In fact, my windows changes are merged into Lars' branch
- Vladimir Panteleev (9/56) Jul 21 2011 I didn't know it was possible to wrap a Windows pipe in a FILE. Neither ...
- Andrej Mitrovic (2/4) Jul 21 2011 I've run into this issue as well. How low is it exactly?
- Vladimir Panteleev (6/10) Jul 21 2011 Seems to be 60, including the 3 standard streams.
- Steven Schveighoffer (17/34) Jul 22 2011 Well, under the hood, the runtime ends up using Windows HANDLES. In fac...
Hello. I have a specific problem. I need to redirect console output from a console program to dfl textbox but i cant find function to do it. std.process.system only shows exiting code. I think std.process.shell should do it but it is crashing whole program. If You don't know what im asking for there's code how i've done it *CODE BEGINS Process p = new Process(); p.StartInfo.FileName = "shutdown"; p.StartInfo.Arguments = " /?"; p.StartInfo.UseShellExecute = false; p.StartInfo.RedirectStandardOutput = true; p.StartInfo.CreateNoWindow = true; p.Start(); string output = p.StandardOutput.ReadToEnd(); textBox3.Text = output; *CODE ENDS Can you provide me an idea what im doing wrong or alternative to popen in D langauge? Regards.
Jul 21 2011
On Thu, 21 Jul 2011 16:19:12 +0300, Maraco <darkandan windowslive.com> wrote:Hello. I have a specific problem. I need to redirect console output from a console program to dfl textbox but i cant find function to do it. std.process.system only shows exiting code. I think std.process.shell should do it but it is crashing whole program. If You don't know what im asking for there's code how i've done it *CODE BEGINS Process p = new Process(); p.StartInfo.FileName = "shutdown"; p.StartInfo.Arguments = " /?"; p.StartInfo.UseShellExecute = false; p.StartInfo.RedirectStandardOutput = true; p.StartInfo.CreateNoWindow = true; p.Start(); string output = p.StandardOutput.ReadToEnd(); textBox3.Text = output; *CODE ENDS Can you provide me an idea what im doing wrong or alternative to popen in D langauge? Regards.This functionality is currently not implemented in D's standard library. Lars Kyllingstad implemented this in his version of std.process, but only supporting the POSIX API. For Windows, you'll need to do it manually, in the same way as in C: http://msdn.microsoft.com/en-us/library/ms682499(v=vs.85).aspx (In my own projects, I just redirect the output to a temporary file.) -- Best regards, Vladimir mailto:vladimir thecybershadow.net
Jul 21 2011
Ok so i need to wait until process will exit and read output from file that process wrote, am i right?
Jul 21 2011
On Thu, 21 Jul 2011 16:38:09 +0300, Maraco <darkandan windowslive.com> wrote:Ok so i need to wait until process will exit and read output from file that process wrote, am i right?Here's how I do it (warning: not very good D1 code): https://github.com/CyberShadow/Team15/blob/master/Utils.d#L1024 -- Best regards, Vladimir mailto:vladimir thecybershadow.net
Jul 21 2011
On Thu, 21 Jul 2011 09:33:34 -0400, Vladimir Panteleev <vladimir thecybershadow.net> wrote:On Thu, 21 Jul 2011 16:19:12 +0300, Maraco <darkandan windowslive.com> wrote:In fact, my windows changes are merged into Lars' branch (https://github.com/kyllingstad/phobos/tree/new-std-process) *BUT* (and this is a big but), dmc's runtime incorrectly handles pipes with C's stdio (i.e. FILE *). Since everything in D right now is FILE * based, it means you can't use pipes at all. However, I have submitted a patch for DMC's runtime to Walter. Hopefully it will be approved in the near future, and then we can work on merging the new std.process into phobos. -SteveHello. I have a specific problem. I need to redirect console output from a console program to dfl textbox but i cant find function to do it. std.process.system only shows exiting code. I think std.process.shell should do it but it is crashing whole program. If You don't know what im asking for there's code how i've done it *CODE BEGINS Process p = new Process(); p.StartInfo.FileName = "shutdown"; p.StartInfo.Arguments = " /?"; p.StartInfo.UseShellExecute = false; p.StartInfo.RedirectStandardOutput = true; p.StartInfo.CreateNoWindow = true; p.Start(); string output = p.StandardOutput.ReadToEnd(); textBox3.Text = output; *CODE ENDS Can you provide me an idea what im doing wrong or alternative to popen in D langauge? Regards.This functionality is currently not implemented in D's standard library. Lars Kyllingstad implemented this in his version of std.process, but only supporting the POSIX API. For Windows, you'll need to do it manually, in the same way as in C: http://msdn.microsoft.com/en-us/library/ms682499(v=vs.85).aspx
Jul 21 2011
On Thu, 21 Jul 2011 18:47:03 +0300, Steven Schveighoffer <schveiguy yahoo.com> wrote:On Thu, 21 Jul 2011 09:33:34 -0400, Vladimir Panteleev <vladimir thecybershadow.net> wrote:I didn't know it was possible to wrap a Windows pipe in a FILE. Neither did I know that the source to DMC's runtime is available. Would it be possible to fix the ridiculously low open FILE limit on Windows as well? -- Best regards, Vladimir mailto:vladimir thecybershadow.netOn Thu, 21 Jul 2011 16:19:12 +0300, Maraco <darkandan windowslive.com> wrote:In fact, my windows changes are merged into Lars' branch (https://github.com/kyllingstad/phobos/tree/new-std-process) *BUT* (and this is a big but), dmc's runtime incorrectly handles pipes with C's stdio (i.e. FILE *). Since everything in D right now is FILE * based, it means you can't use pipes at all. However, I have submitted a patch for DMC's runtime to Walter. Hopefully it will be approved in the near future, and then we can work on merging the new std.process into phobos.Hello. I have a specific problem. I need to redirect console output from a console program to dfl textbox but i cant find function to do it. std.process.system only shows exiting code. I think std.process.shell should do it but it is crashing whole program. If You don't know what im asking for there's code how i've done it *CODE BEGINS Process p = new Process(); p.StartInfo.FileName = "shutdown"; p.StartInfo.Arguments = " /?"; p.StartInfo.UseShellExecute = false; p.StartInfo.RedirectStandardOutput = true; p.StartInfo.CreateNoWindow = true; p.Start(); string output = p.StandardOutput.ReadToEnd(); textBox3.Text = output; *CODE ENDS Can you provide me an idea what im doing wrong or alternative to popen in D langauge? Regards.This functionality is currently not implemented in D's standard library. Lars Kyllingstad implemented this in his version of std.process, but only supporting the POSIX API. For Windows, you'll need to do it manually, in the same way as in C: http://msdn.microsoft.com/en-us/library/ms682499(v=vs.85).aspx
Jul 21 2011
On 7/22/11, Vladimir Panteleev <vladimir thecybershadow.net> wrote:Would it be possible to fix the ridiculously low open FILE limit on Windows as well?I've run into this issue as well. How low is it exactly?
Jul 21 2011
On Fri, 22 Jul 2011 01:47:28 +0300, Andrej Mitrovic <andrej.mitrovich gmail.com> wrote:On 7/22/11, Vladimir Panteleev <vladimir thecybershadow.net> wrote:Seems to be 60, including the 3 standard streams. -- Best regards, Vladimir mailto:vladimir thecybershadow.netWould it be possible to fix the ridiculously low open FILE limit on Windows as well?I've run into this issue as well. How low is it exactly?
Jul 21 2011
On Thu, 21 Jul 2011 18:39:31 -0400, Vladimir Panteleev <vladimir thecybershadow.net> wrote:On Thu, 21 Jul 2011 18:47:03 +0300, Steven Schveighoffer <schveiguy yahoo.com> wrote:Well, under the hood, the runtime ends up using Windows HANDLES. In fact, a DMC file descriptor is just an index into a global array of HANDLES. I had to create a druntime function to wrap a HANDLE in a file descriptor (and get the handle from the fd). The bug in the runtime essentially is that when the pipe is closed from the write end, a read of the file descriptor results in EBADF. This makes the FILE * report it as error instead of EOF. In fact, I think the error should be EPIPE, but dmc's low level handler returns BADF no matter what error occurred when doing ReadFile.In fact, my windows changes are merged into Lars' branch (https://github.com/kyllingstad/phobos/tree/new-std-process) *BUT* (and this is a big but), dmc's runtime incorrectly handles pipes with C's stdio (i.e. FILE *). Since everything in D right now is FILE * based, it means you can't use pipes at all. However, I have submitted a patch for DMC's runtime to Walter. Hopefully it will be approved in the near future, and then we can work on merging the new std.process into phobos.I didn't know it was possible to wrap a Windows pipe in a FILE.Neither did I know that the source to DMC's runtime is available.It is if you purchase a license ;)Would it be possible to fix the ridiculously low open FILE limit on Windows as well?It's just a #define, but I'm not sure what the effects would be everywhere. You'd probably have to petition Walter for that. And it's not FILE limit, it's the file descriptor limit (set to 60 in stdio.h). -Steve
Jul 22 2011