mutated has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks, I have a process that normaly gets started in the background ala redhat service.If I run it in the forground

my $foo = `true`; my $err = $? >> 8; system("echo Error code is $err >> /tmp/foo");

$err is 0 but if I run the same code detached from the tty and running in the background $err is 16777215 ..I've tried other proccess calling:
#!/usr/bin/perl exit 0;
returns the same result...am I on crack?

Edited by BazB: added code tags

Replies are listed 'Best First'.
Re: $? funkyness
by Old_Gray_Bear (Bishop) on Feb 11, 2004 at 21:45 UTC
    16777215 looks remarkably like '-1' shifted right eight bits. (In two's complement notation (I think that the term I want).) What we have is "shift the argument to the right and fill in the vacated bits with the sign bit". A physical shift rather than a logical shift, at the hardware level.

    Someone is trying to tell you that something in your backgrounding of the process is going awry. Perhaps a difference in ENV variables between fore- and back-ground. (At a guess.)

    ----
    I Go Back to Sleep, Now.

    OGB

Re: $? funkyness
by bluto (Curate) on Feb 12, 2004 at 00:46 UTC
    Check your PATH environment variable or use full paths to executables (i.e. 'true' should be '/bin/true' or '/usr/bin/true' depending on your machine). I get the same error (16777215) if I replace 'true' with 'bogus').

    bluto