I know this seems like an odd issue, but I was doing some experimental tests with the program itself, and was running into an issue.
I'm using the WScript method to Execute cen64 and then attempting to get the StdOut of it.
This works, unless cen64 actually gets started simulating an n64, when that happens, the ReadLine/Read/ReadAll completely stops the program until cen64 is closed.
If I use something like DIR and read every line, I can get the output while the program is running.
If cen64 gives an error or its usage info, it also reads the lines just fine.
I know, it seems like I'm just complaining over something irrelevant, and yes it doesn't matter at all. Just wondering if you knew why I'm unable to do this.
If you want, I can post the code to my program.
Unable to read program stdout when running.
- MarathonMan
- Site Admin
- Posts: 692
- Joined: Fri Oct 04, 2013 4:49 pm
Re: Unable to read program stdout when running.
It prints to StdErr, not StdOut.
On Linux, I have to redirect using
On Linux, I have to redirect using
Code: Select all
./cen64 ... 2>&1 ...
Re: Unable to read program stdout when running.
For me it is printing to StdOut, as when I changed the code to read from StdErr, I got nothing at all, even at program close. Atleast on StdOut I got the output when the program closed.
I also tried what you mentioned about redirecting stderr to stdout but still it seems to sit there until the program closes.
I also tried what you mentioned about redirecting stderr to stdout but still it seems to sit there until the program closes.
- MarathonMan
- Site Admin
- Posts: 692
- Joined: Fri Oct 04, 2013 4:49 pm
Re: Unable to read program stdout when running.
StdErr should get used though...:gamax92 wrote:For me it is printing to StdOut, as when I changed the code to read from StdErr, I got nothing at all, even at program close. Atleast on StdOut I got the output when the program closed.
I also tried what you mentioned about redirecting stderr to stdout but still it seems to sit there until the program closes.
Code: Select all
62 #define debug(msg) fprintf(stderr, "[AIF]: "#msg"\n")
63 #define debugarg(msg, arg) fprintf(stderr, "[AIF]: "#msg"\n", arg)
64 #else
Code: Select all
140 printf("%.2f VI/s, RCP: %.2f MHZ, VR4300: %.2f MHz\n", vis, hz / 10000,
141 hz / 10000 * 1.5);
Re: Unable to read program stdout when running.
Ahh yeah, I didn't do a debugging compile and was attempting to capture the "... VI/s " messages that the video writes. I'll try that.
EDIT: Yup, that was it. It needed a fflush. Now its capturing the output, thanks!
What exactly do you mean by enable C99?
EDIT: Yup, that was it. It needed a fflush. Now its capturing the output, thanks!
What exactly do you mean by enable C99?
- MarathonMan
- Site Admin
- Posts: 692
- Joined: Fri Oct 04, 2013 4:49 pm
Re: Unable to read program stdout when running.
I thought setbuf was C99, but it turns out it's C89 as well.gamax92 wrote:Ahh yeah, I didn't do a debugging compile and was attempting to capture the "... VI/s " messages that the video writes. I'll try that.
EDIT: Yup, that was it. It needed a fflush. Now its capturing the output, thanks!
What exactly do you mean by enable C99?
http://man7.org/linux/man-pages/man3/setbuf.3.html
Basically, I was going to suggest that you try other buffering modes to see if it impacted something, but alas it does not!
Who is online
Users browsing this forum: No registered users and 1 guest