473,378 Members | 1,122 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

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.Popen.poll() in a loop, to catch the process's termination
-- is
there something else I should be doing?

Oct 12 '07 #1
2 1430
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
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,...
1
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():...
5
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...
2
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...
5
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...
0
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...
0
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...
2
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...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.