473,811 Members | 3,021 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

the secret life of zombies

I'd like a program, call it 'pipe-fitter', that connects and
interactive app
to three named pipes. The program will filter out EOF from the input
pipe, to
keep the interactive program alive for multiple commands. When the
interactive
app dies, by receiving 'exit', say, then we are done with it -- pipe-
fitter
bails out.

I've tried writing pipe-fitter in the shell (infinite loop), C (could
not get
off the ground at all with this one) and now Python. After trying a
few
different approaches, I was turned on to the subprocess module by
someone on
IRC. My program is almost right, except for damn zombies. Here is pipe-
fitter:

https://svn.j-s-n.org/public/i-can-h...pipe-fitter.py

Say we make some fifos in a dir 'pipes'

mkdir pipes
mkfifo pipes/i pipes/o pipes/e

Now we call pipe-fitter thusly:

pipe-fitter.py -d pipes sh -xv

This runs `sh -xv` with stdin, stdout and stderr connected to pipes/i,
pipes/o
and pipes/e respectively. We open three new terminals. In the first
one, we
put:

echo "ls -l" pipes/i

and in the second:

cat pipes/o

and in the third:

cat pipes/e

Once we enter the final command, the 'echo' returns and the text comes
streaming out in the 2nd and 3rd terminals. Wonderful. Now, let's try
`exit`.

echo 'exit' pipes/i

As expected, cat will terminate in the 2nd and 3rd terminals, with the
3rd
terminal displayin:

+ exit
exit

However, pipe-fitter.py is still running. Why is that? It did not
'poll' at
the right time, it seems. If I try stuffing more input into pipes/i, I
get

IOError: [Errno 32] Broken pipe

and pipe-fitter.py finally quits. Not exactly what I was hoping for.

Prowling around with PS, I find that the `sh -xv` called from within
pipe-fitter is a zombie for a spell; if pipe-fitter fails to catch it
at the
right time, there is no avoiding the IOError. I'm using
subprocess.Pope n.poll() in a loop, to catch the process's termination
-- is
there something else I should be doing?

Oct 12 '07 #1
2 1447
Oh, by the way -- I apologize for the poor formatting of this post,
I guess my linewrap setting is wrong for nntp.

Oct 12 '07 #2
I fixed it myself -- I had to install a signal handler and use
nested 'try-expect' stuff. The link points to the new version.
Oct 13 '07 #3

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

Similar topics

0
1723
by: cognite | last post by:
This venue would surely appreciate the cool stuff being done in python on bioinformatics and python's tools for info parsing and extraction (like fulltext indexing, xml tools, parser builders, graphic display, realtime simulation and communities tools like pygame and ...) It's in San Diego February 9-12, 2004. "Session presentations are 45 or 90 minutes long, and tutorials are either a half-day (3 hours) or a full day (6 hours)."
1
1466
by: Robert Brewer | last post by:
I've Googled extensively, but can't figure out what might be causing my Python CGI app to zombie (yes, Tibia, the one I just announced ;). The cgi bit looks like this: def cgi_handler(): import cgi form = cgi.FieldStorage(keep_blank_values=True) params = dict(.value) for key in form])
5
7584
by: Morten Mikkelsen | last post by:
Hi, On my SQL Server 2000, I have a table of data (tblAllData) containing a number of columns, some of which are 'secret'. I have to let some users access the database using ODBC from an Excel sheet, and I would like that they do not know at all that the columns exist. I tried creating a view for them (qryAllData) that only selects the columns that should be visible, but when the creating the ODBC-connection, both the query and the...
2
1698
by: Arnold | last post by:
For some of my secondary students studying bits and bytes, I'd like to make a form in which they can create secret codes with bytes. I'd like the form to have a memo field that can only accept 0s and 1s and spaces. I was envisioning the following: --On after update or so, check the memo and only allow groups of eight 0s and 1s, and only single spaces. --If students typed groups with < or > eight 0s or 1s, show a msgbox to alert the...
5
1937
by: 1 | last post by:
I have discovered the secret of the soul The soul is the emotion. The soul and the emotion are completely nonmaterial existence. The consciousness and the emotion are inseparable, which means each consciousness accompanies the corresponding emotion. We must understand that the whole brain is a energy system besides as a nervous system, which has the basic property of each energy system- the process of energy release and absorb. The...
0
1099
by: Laptop secret | last post by:
HI, We may not aware that the laptop you bring around has abig secret inside. Some of expert may have known it and keep it as secret. If you are fond of browsing in internet you may probably discover it. Read further thru this site and you may find out : http://sharinginfo4.googlepages.com/home
0
257
by: jsnx | last post by:
I'd like a program, call it 'pipe-fitter', that connects and interactive app to three named pipes. The program will filter out EOF from the input pipe, to keep the interactive program alive for multiple commands. When the interactive app dies, by receiving 'exit', say, then we are done with it -- pipe- fitter bails out.
2
1361
by: sanjay.bidi1 | last post by:
I have puzzle in which I need to hash a value comprised of 2 form fields and a shared password before submitting form to external web application. My question is, what are the possibilities for doing something like this in JavaScript? In pseudo code terms I need to: var myHash = someHashFunction("sharedSecret" + form.field1 + form.field2)
0
9727
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9605
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10647
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10133
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7669
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5554
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5692
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4339
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3865
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.