Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 23 Mar 1999 16:50:59 -0500
From:      Charles Owens <owensc@enc.edu>
To:        freebsd-scsi@freebsd.org, nick.hibma@jrc.it
Subject:   amanda changer.c: strange pclose/wait4 result code handling
Message-ID:  <36F80CC3.6FDE916C@enc.edu>

index | next in thread | raw e-mail

[ I'm guessing that this is a good place for me to discuss a
FreeBSD-specific (I think) amanda problem.  If not... sorry.  This was
first posted to the amanda-hackers list with no response. ]

I've been having some trouble getting the chg_chio changer script to
work happily from amtape (v2.4.1p1).  This is on a FreeBSD 3-stable
system... using a MediaLogic AIT tape library.

Calling the chg-chio script by hand works fine.  But when called through
amtape, some of the amtape subcommands (at least: show, taper, current)
produce the error:

        amtape: could not get changer info: 28 1

I traced the problem to the changer_command subroutine and how the exit
code being produced by the changer script is being handled.

Here's a snippet from changer_command() in changer.c, starting just
after we get done waiting for the changer script to finish.

    exitcode = pclose(cmdpipe);
    cmdpipe = NULL;
    /* mark out-of-control changers as fatal error */
    if(WIFSIGNALED(exitcode)) {
        ap_snprintf(number, sizeof(number), "%d", WTERMSIG(exitcode));
        cmd = newvstralloc(cmd,
                           "<error> ",
                           changer_resultstr,
                           " (got signal ", number, ")",
                           NULL);
        amfree(changer_resultstr);
        changer_resultstr = cmd;
        cmd = NULL;
        exitcode = 2;
    } else {
        exitcode = WEXITSTATUS(exitcode);
    }

After the pclose call (first line), exitcode is set to what appears to
me to be the PID of the exiting child... which from my read of the
wait4(2) man pages means that things are happy.  As expected
WIFSIGNALED(exitcode) returns false.  WEXITSTATUS(exitcode) should
return the exit code returned by the exiting child (in this case
chg-chio).  I expect it to be zero, but for some reason I get 141 every
time (but from looking at chg-chio code I'm pretty sure it's not
returning 141).

changer_command returning a non-zero exit code gives the calling
routines the impression that the changer isn't happy somehow.

As an experiement I replaced the WEXITSTATUS line with

        exitcode = 0;

After doing this amtape sub-commands taper, show, etc. work fine!

So, any ideas as to what's really going on here?  Anyone else seen
this?  Is this a FreeBSD 3.x thing?  From what I can tell from the
FreeBSD man pages it should work as is, but it doesn't.

Thanks,
---
-------------------------------------------------------------------------

  Charles N. Owens                               Email:  owensc@enc.edu
                                             http://www.enc.edu/~owensc
  Network & Systems Administrator
  Information Technology Services  "Outside of a dog, a book is a man's
  Eastern Nazarene College         best friend.  Inside of a dog it's
                                   too dark to read." - Groucho Marx
-------------------------------------------------------------------------


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-scsi" in the body of the message



help

Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?36F80CC3.6FDE916C>