[Tutor] Getting exit code in Windows
Victor R. Cardona
vcardon@siue.edu
Mon, 1 Apr 2002 02:26:51 -0600
--PEIAKu/WMn1b1Hv9
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
On Mon, Apr 01, 2002 at 01:19:47AM -0500, Tim Peters wrote:
> [Victor R. Cardona]
> > I am writing a simple shell in python as a small demonstration project.
> > I have figured out how to get the exit code for a process on UNIX using
> > the waitpid function in the os module. Unfortunately, this function does
> > not seem to exist on Windows.
>=20
> os.waitpid() works under Windows in Python 2.3, but we're a long way from
> releasing that.
Yeah!
> > Is there a portable way of getting that kind of information? I know I
> > could use the win32all extensions, but I wanted to make sure there was
> > not a better way.
>=20
> I'm afraid there really isn't. os.system('command string') runs a shell
> command and returns its exit code, so you'd *think* that would be portable
> (at least among systems that *have* "a shell"; for example, Mac Classic d=
oes
> not). But it turns out that the way Microsoft implemented the Win9x shell
> (command.com), os.system() *always* returns 0 on Win9x. command.com does=
n't
> pass along the exit code of the command it ran, it unaccountably and
> uselessly returns its own "hey, I ran a command! that's a success!" 0 ex=
it
> code.
Oh my...
> So you're stuck.
Thanks. I was afraid of that.
-v
--=20
Victor R. Cardona
Powered by SuSE Linux 7.1 (i386) Professional
GPG key ID E81B3A1C
Key fingerprint =3D 0147 A234 99C3 F4C5 BC64 F501 654F DB49 E81B 3A1C
--PEIAKu/WMn1b1Hv9
Content-Type: application/pgp-signature
Content-Disposition: inline
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org
iD8DBQE8qBnLZU/bSegbOhwRAoelAJ4ngeI24ZanjIVI0PR6meOc1wRE6wCePiKK
oTkgL/U99vG8BRtP6AfpkgM=
=0Beu
-----END PGP SIGNATURE-----
--PEIAKu/WMn1b1Hv9--