www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1995/04/26/14:24:30

Date: Wed, 26 Apr 1995 18:24:10 +0200
To: djgpp AT sun DOT soe DOT clarkson DOT edu
From: tony AT nt DOT tuwien DOT ac DOT at (Anton Helm)
Subject: exit()

I just had some troubles with exitcodes:

I left a program, called with a spawnlp() from a second program, with
exit(-2). The result was that spawnlp() returned 254.

Code:

int en;

if((en = spawnlp(...)) )
  {
  printf("Testing errorcodes: %d\n", en);
  /*  do error handling */

  }


From the docs:

void volatile exit(int exit_code);
and
int spawnlp(...)

That means both, the parameter of exit() and the return value of spawnlp()
are int.

I remember having read long time ago that DOS can only handle errorcodes
0...255.
(is that correct ?) Therefore it is not a DJGPP but a DOS problem.

I finally declared 

signed char en;

and got corrrect behavior for negative exitcodes. 

This is just a workaround. What is the correct procedure to deal with
exitcodes (in a portable way) ?


Tony


***************************************************************************
Dipl.-Ing. Anton HELM            *    Private:                            *
Institut fuer Nachrichtentechnik *                                        *
und Hochfrequenztechnik          *    Anton HELM                          *
Guszhausstr. 25/389              *    Gratian-Marx Str. 7/27              *
A-1040 Wien                      *    A-1110 Wien                         *
AUSTRIA                          *    AUSTRIA                             *
                                 ******************************************
PHONE : +43-1-58801-3520         OOOOOOO O    O     O     O O OOOOO OO    O
FAX   : +43-1-5870583               O    O    O     O     O O O     O O   O
email: Anton DOT Helm AT nt DOT tuwien DOT ac DOT at   O    O    O OOO O  O  O O OOO   O  O  O
       tony AT nt DOT tuwien DOT ac DOT at         O    O    O     O  O  O O O     O   O O
**********************************  O     OOOO       OO OO  O OOOOO O    OO

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019