external program crashes when run through subprocess.popen on XP

Discussion in 'Python' started by ckkart, Nov 17, 2008.

  1. ckkart

    ckkart Guest

    Hi,

    on XP when starting a certain external program (plain C calculation
    program which communicates via stdout/fs) from python 2.5 using
    subprocess.Popen the external program crashes. It does not if started
    directly from the XP command prompt. This is not a purely python
    problems since the crash occurs as well if started e.g. from a msys
    bash shell. The only things I find worth mentioning from the windows
    debugging message is that FileVer and ProdVer of msvrct.dll differ, I
    am no windows expert though.

    Any ideas?

    Thanks, Christian
     
    ckkart, Nov 17, 2008
    #1
    1. Advertising

  2. ckkart

    James Harris Guest

    On 17 Nov, 19:15, ckkart <> wrote:
    > Hi,
    >
    > on XP when starting a certain external program (plain C calculation
    > program which communicates via stdout/fs) from python 2.5 using
    > subprocess.Popen the external program crashes. It does not if started
    > directly from the XP command prompt. This is not a purely python
    > problems since the crash occurs as well if started e.g. from a msys
    > bash shell. The only things I find worth mentioning from the windows
    > debugging message is that FileVer and ProdVer of msvrct.dll differ, I
    > am no windows expert though.
    >
    > Any ideas?


    If it helps there is some finished code at

    http://codewiki.wikispaces.com/tester.py

    which used subprocess.Popen and works well under Windows and Linux.
    Search for Popen to locate the specific call. Note that the code works
    whether the shell argument is true or false.

    James
     
    James Harris, Nov 17, 2008
    #2
    1. Advertising

  3. ckkart

    Christan K. Guest

    ckkart <ckkart <at> gmail.com> writes:

    >
    > Hi,
    >
    > on XP when starting a certain external program (plain C calculation
    > program which communicates via stdout/fs) from python 2.5 using
    > subprocess.Popen the external program crashes. It does not if started
    > directly from the XP command prompt. This is not a purely python
    > problems since the crash occurs as well if started e.g. from a msys
    > bash shell. The only things I find worth mentioning from the windows
    > debugging message is that FileVer and ProdVer of msvrct.dll differ, I
    > am no windows expert though.


    I just obseerved that the program does not crash if called via subprocess.call
    so it seems to be related with having a way to communicate with the external
    program or not.

    Christian
     
    Christan K., Nov 18, 2008
    #3
  4. En Tue, 18 Nov 2008 09:41:46 -0200, Christan K. <> escribió:
    > ckkart <ckkart <at> gmail.com> writes:
    >> on XP when starting a certain external program (plain C calculation
    >> program which communicates via stdout/fs) from python 2.5 using
    >> subprocess.Popen the external program crashes. It does not if started
    >> directly from the XP command prompt. This is not a purely python
    >> problems since the crash occurs as well if started e.g. from a msys
    >> bash shell. The only things I find worth mentioning from the windows
    >> debugging message is that FileVer and ProdVer of msvrct.dll differ, I
    >> am no windows expert though.

    >
    > I just obseerved that the program does not crash if called via
    > subprocess.call
    > so it seems to be related with having a way to communicate with the
    > external
    > program or not.


    Maybe the program attempts to write something to stdout/stderr? If you use
    Popen(..., stdout=None, stderr=None, ...) then the subprocess' standard
    handles will be invalid, and it will fail as soon as it attempts to write
    something.

    --
    Gabriel Genellina
     
    Gabriel Genellina, Nov 18, 2008
    #4
  5. ckkart

    ckkart Guest

    On 18 Nov., 21:40, "Gabriel Genellina" <> wrote:
    > En Tue, 18 Nov 2008 09:41:46 -0200, Christan K. <> escribió:
    >
    > > ckkart <ckkart <at> gmail.com> writes:
    > >> on XP when starting a certainexternalprogram (plain C calculation
    > >> program which communicates via stdout/fs) from python 2.5 using
    > >> subprocess.Popen theexternalprogram crashes. It does not if started
    > >> directly from the XP command prompt. This is not a purely python
    > >> problems since the crash occurs as well if started e.g. from a msys
    > >> bash shell. The only things I find worth mentioning from the windows
    > >> debugging message is that FileVer and ProdVer of msvrct.dll differ, I
    > >> am no windows expert though.

    >
    > > I just obseerved that the program does not crash if called via  
    > > subprocess.call
    > > so it seems to be related with having a way to communicate with the  
    > >external
    > > program or not.

    >
    > Maybe the program attempts to write something to stdout/stderr? If you use  
    > Popen(..., stdout=None, stderr=None, ...) then the subprocess' standard  
    > handles will be invalid, and it will fail as soon as it attempts to write  
    > something.


    You were right. I was not capturing stderr, only stdout and that
    crashed the external program. Now it works lik a charm. Thanks a lot.

    Christian
     
    ckkart, Nov 27, 2008
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Earl Eiland
    Replies:
    0
    Views:
    334
    Earl Eiland
    Mar 18, 2005
  2. Earl Eiland
    Replies:
    0
    Views:
    378
    Earl Eiland
    Mar 19, 2005
  3. Replies:
    3
    Views:
    693
  4. Chris Seberino
    Replies:
    6
    Views:
    547
    Chris Seberino
    Jun 16, 2010
  5. Niklas Berliner
    Replies:
    0
    Views:
    165
    Niklas Berliner
    Jan 10, 2013
Loading...

Share This Page