G_fatal_error()'s from G_system()

Darrell McCauley mccauley at ecn.purdue.edu
Sun Jan 2 03:15:57 EST 1994


Has anyone tried to capture errors from G_system/G_fatal_error?
The following seems to function appropriately:

#define ERRMASK 65280 /* 256+512+1024+2048+4096+8192+16384+32768 */
if (((status = G_system(buf)) >> 8) & ERRMASK != 0)
{
  sprintf(buf, "s.sweep failed with a status of %d.", status);
  G_fatal_error(buf);
}

"buf" is a grass command that may terminate by a call to G_fatal_error().
I'm shifting the higher 8 bits, which supposedly contains the error,
and then masking off any remnants. i.e., if a prog returns 1 and there's
nothing "funny" in the lower order bits, then return status will be 256.

Does this seem appropriate?

--D



More information about the grass-dev mailing list