i ran onto this weirdness today: seems like close() on popen-ed
(pseudo)file fails miserably with exception instead of returning exit
code, when said exit code is -1.
here is the simplest example (under Windows): print popen('exit 1').close()
1 print popen('exit -1').close()
Traceback (most recent call last):
File "<interacti ve input>", line 1, in ?
IOError: (0, 'Error') print popen('exit -2').close()
-2
has anyone have idea why is that?
- nas 8 3736
Atanas Banov: i ran onto this weirdness today: seems like close() on popen-ed (pseudo)file fails miserably with exception instead of returning exit code, when said exit code is -1.
Not here.
Python 2.4.2 (#67, Sep 28 2005, 12:41:11) [MSC v.1310 32 bit (Intel)]
Type "help", "copyright" , "credits" or "license" for more information. import os print os.popen('exit 1').close()
1
--
René Pijlman
my gripe is about exit with MINUS ONE, not +1. see my post again.
yes, i know one cannot return -1 in unix (since returned value is
exitcode % 256 * 256), and no, i am not interested in unix behavior.
Rene Pijlman wrote: Atanas Banov:i ran onto this weirdness today: seems like close() on popen-ed (pseudo)file fails miserably with exception instead of returning exit code, when said exit code is -1.
Not here.
Python 2.4.2 (#67, Sep 28 2005, 12:41:11) [MSC v.1310 32 bit (Intel)] Type "help", "copyright" , "credits" or "license" for more information. import os print os.popen('exit 1').close()
1
Atanas Banov wrote: i ran onto this weirdness today: seems like close() on popen-ed (pseudo)file fails miserably with exception instead of returning exit code, when said exit code is -1.
here is the simplest example (under Windows):
print popen('exit 1').close() 1 print popen('exit -1').close() Traceback (most recent call last): File "<interacti ve input>", line 1, in ? IOError: (0, 'Error') print popen('exit -2').close()
-2
has anyone have idea why is that?
_PyPclose returns the exit status of the popened process (the popenee?),
or -1 on error. Of course, if the status is supposed to be -1, there's
some confusion.
In the snippet of code below (from Modules/posixmodule.c), result has
been initialized to the output of fclose, which in your case is 0. The
comment is particularly handy.
if (result != EOF &&
waitpid(pipe_pi d, &exit_code, 0) == pipe_pid)
{
/* extract exit status */
if (WIFEXITED(exit _code))
{
result = WEXITSTATUS(exi t_code);
}
else
{
errno = EPIPE;
result = -1;
}
}
else
{
/* Indicate failure - this will cause the file object
* to raise an I/O error and translate the last
* error code from errno. We do have a problem with
* last errors that overlap the normal errno table,
* but that's a consistent problem with the file object.
*/
result = -1;
}
"Atanas Banov" <en****@gmail.c om> wrote in message
news:11******** **************@ g47g2000cwa.goo glegroups.com.. . my gripe is about exit with MINUS ONE, not +1. see my post again.
FWIW, I reproduced the error message for -1 (and the no error for -2, -3)
in the Idle Python Shell uder Win XP home.
tjr
Jeffrey Schwab wrote: _PyPclose returns the exit status of the popened process (the popenee?), or -1 on error. Of course, if the status is supposed to be -1, there's some confusion.
yes, that's what i thought the root of the problem is.
In the snippet of code below (from Modules/posixmodule.c), result has been initialized to the output of fclose, which in your case is 0. The comment is particularly handy.
.... /* Indicate failure - this will cause the file object * to raise an I/O error and translate the last * error code from errno. We do have a problem with * last errors that overlap the normal errno table, * but that's a consistent problem with the file object. */
the piece you quoted is from the unix #ifdef part, i think. there is
another version of the pypclose for windows below that.
in any event i think such behaviour is a bug - just because in unix
exit codes are limited to 0..255 (and returned multiplied by 256)
doesnt mean other OSes should suffer because of design flow in
_PyPclose, right?
throwing an IOError "no error" doesnt help.
is there a bug database for python where i can check if this was
discussed?
Atanas Banov wrote: Jeffrey Schwab wrote:
_PyPclose returns the exit status of the popened process (the popenee?), or -1 on error. Of course, if the status is supposed to be -1, there's some confusion.
yes, that's what i thought the root of the problem is.
In the snippet of code below (from Modules/posixmodule.c), result has been initialized to the output of fclose, which in your case is 0. The comment is particularly handy.
....
/* Indicate failure - this will cause the file object * to raise an I/O error and translate the last * error code from errno. We do have a problem with * last errors that overlap the normal errno table, * but that's a consistent problem with the file object. */
the piece you quoted is from the unix #ifdef part, i think. there is another version of the pypclose for windows below that.
in any event i think such behaviour is a bug - just because in unix exit codes are limited to 0..255 (and returned multiplied by 256) doesnt mean other OSes should suffer because of design flow in _PyPclose, right?
throwing an IOError "no error" doesnt help.
is there a bug database for python where i can check if this was discussed?
Yes, there's a bug database linked from python.org; search the main page
for "Bugs".
Here's the most (seemingly) relevant bug report I can find: http://sourceforge.net/tracker/index...70&atid=105470
Still:
phase:toby:~> echo 'exit -1' | bash
phase:toby:~> echo $?
255
phase:toby:~>
Jeffrey Schwab wrote: Atanas Banov wrote:
i ran onto this weirdness today: seems like close() on popen-ed (pseudo)file fails miserably with exception instead of returning exit code, when said exit code is -1.
here is the simplest example (under Windows):
> print popen('exit 1').close()
1
> print popen('exit -1').close()
Traceback (most recent call last): File "<interacti ve input>", line 1, in ? IOError: (0, 'Error')
> print popen('exit -2').close()
-2
has anyone have idea why is that?
_PyPclose returns the exit status of the popened process (the popenee?), or -1 on error. Of course, if the status is supposed to be -1, there's some confusion.
In the snippet of code below (from Modules/posixmodule.c), result has been initialized to the output of fclose, which in your case is 0. The comment is particularly handy.
if (result != EOF && waitpid(pipe_pi d, &exit_code, 0) == pipe_pid) { /* extract exit status */ if (WIFEXITED(exit _code)) { result = WEXITSTATUS(exi t_code); } else { errno = EPIPE; result = -1; } } else { /* Indicate failure - this will cause the file object * to raise an I/O error and translate the last * error code from errno. We do have a problem with * last errors that overlap the normal errno table, * but that's a consistent problem with the file object. */ result = -1; }
*** Free account sponsored by SecureIX.com ***
*** Encrypt your Internet usage with a free VPN account from http://www.SecureIX.com ***
Tobiah wrote: phase:toby:~> echo 'exit -1' | bash phase:toby:~> echo $? 255 http://www.linuxtopia.org/online_boo...exitcodes.html
Exit Code Number: 255 [1]
Meaning: Exit status out of range
Example: exit -1
Comments: exit takes only integer args in the range 0 - 255
[1] Out of range exit values can result in unexpected exit codes. An
exit value greater than 255 returns an exit code modulo 256. For
example, exit 3809 gives an exit code of 225 (3809 % 256 = 225). This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: zapazap |
last post by:
Dear Snake Charming Gurus,
(Was: http://mail.python.org/pipermail/python-list/2004-January/204454.html)
First, a thank you to Tim Golden, Thomas Heller, and Mark Hammond
for your earlier help with this problem. I am uncertain about what
etiquette calls for, but more on that later.
My Objective:
I am trying to control the _VMWare Desktop_ application
|
by: Tim Black |
last post by:
In my recent experience, popen os pipes always fail when cwd is a UNC
path. Can anyone shed any light on this? Although I've seen lots of
UNC path-related problems in this newsgroup, I've not been able to
find anything specifically about os pipes and UNC paths.
Here's a session dump that demonstrates what I'm talking about:
Python 2.3.4 (#53, May 25 2004, 21:17:02)
on win32
Type "help", "copyright", "credits" or "license" for more...
|
by: Mark Sandler |
last post by:
Hi,
When i create a process using popen and then if i decide that i am not
interested in keeping the process pipes anymore, and I forget the
correspond variables . Then, if python tries to destroy pipes and get locked on
pipe.close(), until the child process terminates... While this seem to
follow specifications (close waits until pipes closes on the other end,
and destructor calls close()),
it seems like a rather weird behaviour to me:...
|
by: David Mathog |
last post by:
If this:
int i,sum;
int *array;
for(sum=0, i=0; i<len; i++){
sum += array;
}
is converted to this (never mind why for the moment):
|
by: rveloso |
last post by:
Hi all, i'm having a really nasty problem with popen.
I have the following code :
---------------------
....
FILE *PD;
....
sprintf(fname,"/usr/bin/gzip -dc %s/%s",dirname,dp->d_name);
....
if((PD = popen(fname, "r"))==NULL){
fprintf(stderr,"%d: Failed opening pipe to %s\n",errno,fname);
| |
by: Greg Strong |
last post by:
Hello All,
Is there any way to close an ODBC connection via DSN without completely
closing the Access front-end?
I'm doing some testing with using Access as a front-end to Oracle 10g
Express edition. When the user ID and password is entered on a form and
after a successful connection it seems Access doesn't change the
connection. Even if I enter an invalid user ID and/or password the
connection continues to work.
|
by: Doru Moisa |
last post by:
Hello,
How can I capture the output of a long runnning process which I open
with popen() ?
I tried reading line by line, char by char, but the result always
comes when the process finishes.
(I am trying to make a wx.python program that opens some "make ..."
with popen). How can I receive the output of the program immediatly,
so that I can show a progressbar in my application ?
I always get the program's output after it finished...
|
by: Angus |
last post by:
I have a socket class CTestClientSocket which I am using to simulate
load testing.
I create multiple instances of the client like this:
for (int i = 0; i < 5; i++)
{
CTestClientSocket* pTemp = new CTestClientSocket(this, ip, port);
pTemp->Connect();
m_collClients.push_back(pTemp);
|
by: revenant81 |
last post by:
I'm writing a program which has to execute a command, get its output
and show it on a treeview.
This command runs for a very long time.
I want to end the execution of the command when the user closes my
application.
Right now I'm using an object my_child of type subprocess.Popen to
execute the command, inside a thread with an infinite loop where we
constantly ask for its output.
|
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...
|
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,...
| |
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...
|
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 launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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...
|
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 into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |