473,545 Members | 2,009 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

process steering with pipes

Hi,

does anyone have an idea for this problem:

I use anonymous pipes to steer a console program under Win2000 with a
second 'steering aplication'. The stdin and output are redirected to
pipes.

The console application has several fgets() and fgetc() to read
strings and chars. This works very fine with the pipes.

But, there is one point where the console application uses kbhit() and
waits for a key to be hit. It seems not possible to use the pipes to
get out of the loop

while( ! kbhit() )...
I do not want to use the keyboard and I can not change the console
application, since I do not have the sources.

Is there a way to make the one program simulate this event in a way
that the console application's line while(!kbhit()) ... is satisfied?

Thanks a lot,
Hans J. Brinksmeyer
Nov 14 '05 #1
9 2540
On Thu, 02 Dec 2004 08:30:13 -0800, Hans J?rg Brinksmeyer wrote:
Hi,

does anyone have an idea for this problem:

I use anonymous pipes to steer a console program under Win2000 with a
second 'steering aplication'. The stdin and output are redirected to
pipes.

The console application has several fgets() and fgetc() to read
strings and chars. This works very fine with the pipes.

But, there is one point where the console application uses kbhit() and
waits for a key to be hit. It seems not possible to use the pipes to
get out of the loop

while( ! kbhit() )...

Unfortunately kbit() (and indeed "anonymous pipes") are not defined by the
C programming language, they are Windows related features. A good place
to discuss them would be comp.os.ms-windows.program mer.win32.
I do not want to use the keyboard and I can not change the console
application, since I do not have the sources.

Is there a way to make the one program simulate this event in a way that
the console application's line while(!kbhit()) ... is satisfied?


Again, the C language doesn't begin to address an issue like this, ask the
Windows experts.

Lawrence
Nov 14 '05 #2
"Lawrence Kirby"
Hans J?rg Brinksmeyer wrote:

[OT OP snipped]
Unfortunately kbit() (and indeed "anonymous pipes") are not defined by the
C programming language, they are Windows related features. A good place
to discuss them would be comp.os.ms-windows.program mer.win32.


Rats! I thought not having to deal with crappy plumbing was the silver
lining to using my platform. A fresh hell awaits.... MPJ
Nov 14 '05 #3
Merrill & Michele wrote:
"Lawrence Kirby"
Hans J?rg Brinksmeyer wrote:


[OT OP snipped]
Unfortunately kbit() (and indeed "anonymous pipes") are not defined by the
C programming language, they are Windows related features. A good place
to discuss them would be comp.os.ms-windows.program mer.win32.


Rats! I thought not having to deal with crappy plumbing was the silver
lining to using my platform. A fresh hell awaits.... MPJ


Now what does this add to the discussion other than noise? Every
article need not be treated as a fresh opportunity for a "witty"
comment. I am not ROTFLMAO.

--
Chuck F (cb********@yah oo.com) (cb********@wor ldnet.att.net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home .att.net> USE worldnet address!
Nov 14 '05 #4
> A good place
to discuss them would be comp.os.ms-windows.program mer.win32.


Lawrence,

thank you for this hint. I'm not a C expert ;-)
Since I thought the console app is designed in plain C I have choosen
this forum here.

Best regards,
Hans
Nov 14 '05 #5

"CBFalconer "
Merrill & Michele wrote:
"Lawrence Kirby"
Hans J?rg Brinksmeyer wrote:


[OT OP snipped]
Unfortunately kbit() (and indeed "anonymous pipes") are not defined by the C programming language, they are Windows related features. A good place
to discuss them would be comp.os.ms-windows.program mer.win32.


Rats! I thought not having to deal with crappy plumbing was the silver
lining to using my platform. A fresh hell awaits.... MPJ


Now what does this add to the discussion other than noise? Every
article need not be treated as a fresh opportunity for a "witty"
comment. I am not ROTFLMAO.


Every five minutes, a unix user posts something about pipes not working. I
didn't think it was an issue for my platform, but apparently it is. I was
happy to learn simultaneously of the existence and non-conforming nature of
anonymous pipes. MPJ
Nov 14 '05 #6
If this is REALLY what you've got to do then the remote process and use some
assembly code and do "out"'s to the chip that handles the KB IO. This is
typically an 8048 or 8042 Intel chip, and the port to out to is 60H. Once
this port is written to the 8259 Interrupt controller will fire, and you
could get the address from there instead and just fire that int handler.

An easier way may be to use the MS-DOS interrupt 09 (INT 09) which is a BIOS
handler for the keyboard.

A HUGE downside is that you have to have a controller system where you know
a user is NOT at the keyboard. It is actually a big kluge that I would NEVER
do. Why do you need to use a pipe anyways? Is the code already written for
the process that you are piping to?

"Hans J?rg Brinksmeyer" <ha************ ********@iav.de > wrote in message
news:9f******** *************** ***@posting.goo gle.com...
Hi,

does anyone have an idea for this problem:

I use anonymous pipes to steer a console program under Win2000 with a
second 'steering aplication'. The stdin and output are redirected to
pipes.

The console application has several fgets() and fgetc() to read
strings and chars. This works very fine with the pipes.

But, there is one point where the console application uses kbhit() and
waits for a key to be hit. It seems not possible to use the pipes to
get out of the loop

while( ! kbhit() )...
I do not want to use the keyboard and I can not change the console
application, since I do not have the sources.

Is there a way to make the one program simulate this event in a way
that the console application's line while(!kbhit()) ... is satisfied?

Thanks a lot,
Hans J. Brinksmeyer

Nov 14 '05 #7
mef526 <mi******@remov ecodeinsight.co m> scribbled the following:
If this is REALLY what you've got to do then the remote process and use some
assembly code and do "out"'s to the chip that handles the KB IO. This is
typically an 8048 or 8042 Intel chip, and the port to out to is 60H. Once
this port is written to the 8259 Interrupt controller will fire, and you
could get the address from there instead and just fire that int handler. An easier way may be to use the MS-DOS interrupt 09 (INT 09) which is a BIOS
handler for the keyboard. A HUGE downside is that you have to have a controller system where you know
a user is NOT at the keyboard. It is actually a big kluge that I would NEVER
do. Why do you need to use a pipe anyways? Is the code already written for
the process that you are piping to?


Could you please discuss implementation-specific issues on an
implementation-specific newsgroup? This might come as a shock to you,
but not all systems have MS-DOS interrupts.

--
/-- Joona Palaste (pa*****@cc.hel sinki.fi) ------------- Finland --------\
\-------------------------------------------------------- rules! --------/
"As we all know, the hardware for the PC is great, but the software sucks."
- Petro Tyschtschenko
Nov 14 '05 #8
On Fri, 03 Dec 2004 00:19:19 -0800, Hans J?rg Brinksmeyer wrote:
A good place
to discuss them would be comp.os.ms-windows.program mer.win32.


Lawrence,

thank you for this hint. I'm not a C expert ;-)
Since I thought the console app is designed in plain C I have choosen
this forum here.


It is possible to run standard C apps as console applications, just as it
is possible to, say, run them from a Unix shell command prompt. However
each platform provides a myriad of extensions (i.e. non-standard features)
that can also be used (AFAIK console application can use pretty much the
full Win32 API). Your question was about keyboards and kbhit() which are
not covered by standard C, i.e. one of those extensions.

Lawrence

Nov 14 '05 #9
Hans J?rg Brinksmeyer wrote:
Hi,

does anyone have an idea for this problem:

I use anonymous pipes to steer a console program under Win2000 with a
second 'steering aplication'. The stdin and output are redirected to
pipes.

The console application has several fgets() and fgetc() to read
strings and chars. This works very fine with the pipes.

But, there is one point where the console application uses kbhit() and
waits for a key to be hit. It seems not possible to use the pipes to
get out of the loop

while( ! kbhit() )...
I do not want to use the keyboard and I can not change the console
application, since I do not have the sources.

Is there a way to make the one program simulate this event in a way
that the console application's line while(!kbhit()) ... is satisfied?

Thanks a lot,
Hans J. Brinksmeyer


I do not think so. The problem is that kbhit() probably doesn't use
stdin or stdout at all but reads directly from the keyboard...
Nov 14 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2586
by: Peter Åstrand | last post by:
There's a new PEP available: PEP 324: popen5 - New POSIX process module A copy is included below. Comments are appreciated. ---- PEP: 324 Title: popen5 - New POSIX process module
18
4863
by: jas | last post by:
Hi, I would like to start a new process and be able to read/write from/to it. I have tried things like... import subprocess as sp p = sp.Popen("cmd.exe", stdout=sp.PIPE) p.stdin.write("hostname\n") however, it doesn't seem to work. I think the cmd.exe is catching it.
3
1814
by: norm4h8 | last post by:
Hi! I have a question about how to create a process in such a way that it would terminate itself if its wated for input for too long. Here is the story. I have 2 different files, say R.c and S.c, which have a named pipe between them and send each other signals. R process starts first, it opens a named pipe and waits for S to connect. S...
13
5088
by: bayer.justin | last post by:
Hi, I am trying to communicate with a subprocess via the subprocess module. Consider the following example: <subprocess.Popen object at 0x729f0> Here hey is immediately print to stdout of my interpreter, I did not type in the "hey". But I want to read from the output into a string, so I do
2
1446
by: kirk | last post by:
Can someone tell me the cleanest way to achieve this --> I have a running C# tray application. It has a tray menu to let the user turn on and off things, like monitoring the CPU usage for example. Now lets say I have maybe a batch/jscript somewhere and it wants to do some work and then send a command off to my tray app to tell it "turn...
7
1786
by: ecir.hana | last post by:
Hello, just to recap: last time I asked how to do an interprocess communitation, between one Manager process (graphical beckend) and some Worker processes. I decided to go with sockets, thanks for replies, once more. However, I would like to ask another thing: I would like to collect everyting what the Workers print and display in...
5
4950
by: Mirxon | last post by:
Hello, I'm working on a C program under Ubuntu. It's basd on socket. Browser calls a client cgi (C program), and send some parameters to server (C program). Server runs another program (ooimpress, open office ppt), and translate the commands from client to a key event, and send it to child process. For example.
3
1485
by: Michael Justin | last post by:
Mufasa wrote: Message Oriented Middleware might be an option too: http://en.wikipedia.org/wiki/Message-oriented_middleware There are many very good (including Open Source implementations) and most of them support .NET, so you can have active and passive components on the client. The message broker can notify the client about new
5
9722
by: Markgoldin | last post by:
I am searching for a solution of sending messages from not .Net process into a .Net process written in C#. I have gone already thru sockets solution and have porblems with it. I am not a C# coder dont kill :) I am thinking about something like this: A remote non .Net process has a window with a name known to .Net program. Can .Net program...
0
7475
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7409
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7664
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7437
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7771
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5982
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
4958
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3446
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1023
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.