Re: [fpc-pascal] Redirecting input to a child process

2011-05-08 Thread Anton Shepelev
SteveG: > Anton - I have attached an extract from some work- > ing code (hopefully I didnt remove anything neces- > sary) > It may help you move on a bit further I turned your piece of code into a complete program, but it didn't work either. In fact, there is not much difference between yo

Re: [fpc-pascal] Redirecting input to a child process

2011-05-08 Thread SteveG
On 08/05/11 17:30, Anton Shepelev wrote: SteveG: Anton - I have attached an extract from some work- ing code (hopefully I didnt remove anything neces- sary) It may help you move on a bit further I turned your piece of code into a complete program, but it didn't work either. In fact, there

Re: [fpc-pascal] Re: Compiling Synapse... begginer questions

2011-05-08 Thread Marco van de Voort
In our previous episode, Marcos Douglas said: > > My second question: > > Why the compiler do not found the units in > > \freepascal\lib\synapse\src\trunk\units\i386-win32 if I use the > > compiler option Fu (in Lazarus is Other Units Files -Fu)? In > > this folder there exists all .ppu and .o comp

Re: [fpc-pascal] Redirecting input to a child process

2011-05-08 Thread Marco van de Voort
In our previous episode, Anton Shepelev said: >MoreProcess.CommandLine := 'C:\WINDOWS\system32\cmd.exe /C more'; Why do you execute over the shell? You now pipe your information into the shell (since that is what you execute directly), not the program. ___

Re: [fpc-pascal] Redirecting input to a child process

2011-05-08 Thread Anton Shepelev
SteveG: > This is working on Linux and WinXP > > I cut what I was hoping was just the relevant code > from the unit, so it is missing a bit :) Here's a full program made from this code: http://pastebin.com/id90J1rY It doesn't work for me in WinXP. What about you? Anton

Re: [fpc-pascal] Redirecting input to a child process

2011-05-08 Thread Anton Shepelev
Marco van de Voort: > Why do you execute over the shell? You now pipe > your information into the shell (since that is > what you execute directly), not the program. Thanks for the note, Marco. Unfortunately, replacing that line with the direct path to more.com had no effect. When exe

Re: [fpc-pascal] Redirecting input to a child process

2011-05-08 Thread Marco van de Voort
In our previous episode, Anton Shepelev said: > > When executing command-line programs via the shell, > isn't the shell's input redirected to the program's? Maybe. I'm pretty sure about batchfiles, but never tried programs, that's why I thought I'd mention the observation. __

Re: [fpc-pascal] Redirecting input to a child process

2011-05-08 Thread Anton Shepelev
Marco van de Voort: > > When executing command-line programs via the > > shell, isn't the shell's input redirected to the > > program's? > > Maybe. I'm pretty sure about batchfiles, but never > tried programs, that's why I thought I'd mention > the observation. My program captures both the

Re: [fpc-pascal] Redirecting input to a child process

2011-05-08 Thread Marco van de Voort
In our previous episode, Anton Shepelev said: > > > shell, isn't the shell's input redirected to the > > > program's? > > > > Maybe. I'm pretty sure about batchfiles, but never > > tried programs, that's why I thought I'd mention > > the observation. > > My program captures both the standard and

Re: [fpc-pascal] Redirecting input to a child process

2011-05-08 Thread Anton Shepelev
Marco van de Voort: > I played a bit with it, but was unable to make it work. I > added a writeln of outstream.size to the "running" while, > and it seems output is written. Many thanks :) If I understood you correctly, you put WriteLn(MoreProcess.Output.Size); inside the waiting loop an

RE : [fpc-pascal] Redirecting input to a child process

2011-05-08 Thread Ludo Brands
If you run 'more' in a cmd window you'll notice that 'more' echoes the input but only sends to stdout when a return is entered. I modified the program to send 'Anton'#10 and the program reads back 'Anton'#10 from stdout. Ludo -Message d'origine- De : fpc-pascal-boun...@lists.freepascal.

RE : RE : [fpc-pascal] Redirecting input to a child process

2011-05-08 Thread Ludo Brands
Correction: 'Anton'#13#10 is read from stdout. More adds the CR. Windows style EOL ... Ludo -Message d'origine- De : fpc-pascal-boun...@lists.freepascal.org [mailto:fpc-pascal-boun...@lists.freepascal.org] De la part de Ludo Brands Envoyé : dimanche 8 mai 2011 19:06 À : 'FPC-Pascal users

RE : [fpc-pascal] Redirecting input to a child process

2011-05-08 Thread Anton Shepelev
Ludo Brands: > If you run 'more' in a cmd window you'll notice that > 'more' echoes the input but only sends to stdout when a > return is entered. I modified the program to send > 'Anton'#10 and the program reads back 'Anton'#10 from > stdout. Thank you, Ludo, this is great

Re: RE : [fpc-pascal] Redirecting input to a child process

2011-05-08 Thread Anton Shepelev
Ludo Brands: > If you run 'more' in a cmd window you'll notice that > 'more' echoes the input but only sends to stdout when a > return is entered. I modified the program to send > 'Anton'#10 and the program reads back 'Anton'#10 from > stdout. Connected with this remark, is

RE : RE : [fpc-pascal] Redirecting input to a child process

2011-05-08 Thread Ludo Brands
Anton, I don't see where you close the mProcess.input. I tried several things myself which didn't work: - ctrl Z Return is an eof when you run more in a cmd window. - call explicitly CloseHandle(mProcess.Input.Handle); Pipes.pp doesn't have any routines to clean up the pipe handles which is acc

RE : RE : [fpc-pascal] Redirecting input to a child process

2011-05-08 Thread Ludo Brands
The handles are mProcess.Input.Handle and mProcess.Output.Handle Ludo -Message d'origine- De : fpc-pascal-boun...@lists.freepascal.org [mailto:fpc-pascal-boun...@lists.freepascal.org] De la part de Anton Shepelev Envoyé : dimanche 8 mai 2011 19:27 À : FPC-Pascal users discussions Objet :

Re: RE : [fpc-pascal] Redirecting input to a child process

2011-05-08 Thread waldo kitty
On 5/8/2011 13:17, Anton Shepelev wrote: Ludo Brands: If you run 'more' in a cmd window you'll notice that 'more' echoes the input but only sends to stdout when a return is entered. I modified the program to send 'Anton'#10 and the program reads back 'Anton'#10 from stdou

RE : RE : [fpc-pascal] Redirecting input to a child process

2011-05-08 Thread Ludo Brands
That's what I tried already. It simply echoes the ^Z (right arrow). I tried also to close the pipe explicitly from the sender side without success: mProcess.CloseInput; CloseHandle(mProcess.Input.Handle); I'm afraid we're looking at a problem with more.com waiting until the process releases the

RE : RE : [fpc-pascal] Redirecting input to a child process

2011-05-08 Thread Ludo Brands
Anton, According to msdn http://msdn.microsoft.com/en-us/library/aa365782%28v=vs.85%29.aspx the pipe handles should be created non-inheritable in order to detect EOF. Looking at fcl-process/src/win/pipes.inc, pipes are created inheritable... The msdn sample code to redirect input and output also c

Re: [fpc-pascal] Redirecting input to a child process

2011-05-08 Thread Anton Shepelev
waldo kitty: > how about sending the ^Z line the CRLF is being sent to > indicate line breaks?? This I had tried even before posting the question :) Ludo Brands: > I don't see where you close the mProcess.input. In my original post I call: MoreProcess.CloseInput(); As for the progra

[fpc-pascal] Shootout: k-nucleotide implementation (was: Which programming language is fastest?)

2011-05-08 Thread Bernd
Ok, I have looked at the example that was the slowest: 5 times slower than gcc. k-nucleitide: http://shootout.alioth.debian.org/u32/benchmark.php?test=knucleotide&lang=all The C++ code is giving me headaches from only looking at it. I am still not sure what the hell they have done (or cheated) t

Re: RE : RE : [fpc-pascal] Redirecting input to a child process

2011-05-08 Thread Anton Shepelev
Ludo Brands: > > Connected with this remark, is there a way to get the > > underlying StdIn handle in a FreePascal program, so as > > to read from it per-character, or any other way using > > the OS's routines? > > The handles are mProcess.Input.Handle and mProcess.Out- > put.Handle I

Re: [fpc-pascal] Redirecting input to a child process

2011-05-08 Thread Anton Shepelev
I wrote: > I'll try duplicating the handles and report the results. Yes. It works now. I am creating a non-inheritable handle using CreatePipe, then duplicating it to an inheritable one using DuplicateHandle and pass the duplicate to the CreateProcess funtion. Does this mean that th

Re: [fpc-pascal] Redirecting input to a child process

2011-05-08 Thread waldo kitty
On 5/8/2011 16:16, Anton Shepelev wrote: waldo kitty: how about sending the ^Z line the CRLF is being sent to indicate line breaks?? This I had tried even before posting the question :) i wasn't sure and the posts didn't seem to indicate this so i thought i'd ask ;) now i'll go back to