At Wed, 9 Mar 2022 22:50:29 -0500 (EST) Robert Heller <[email protected]> wrote:
> > At Wed, 9 Mar 2022 19:11:40 -0500 Nathan Stratton Treadway > <[email protected]> wrote: > > > > > On Tue, Mar 08, 2022 at 18:27:47 -0500, Robert Heller wrote: > > > > > > I've written a Java program that goes through vaulted tapes and forks > > > amtape > > > (using Runtime.getRuntime().exec(()), and when a non-existant tape label > > > is > > > asked for, amtape "hangs". I cannot figure out why or how to get amtape > > > to > > > just exit with an error (which I can then handle). > > > > Does it still hang if you pass an argument "-ointeractivity=''" when you > > exec amtape? > > Did not try that. OK, it still hangs. Here is the Java fragment: public class FlushOldVaults extends BackupVault { private static final String AMTAPE = "/usr/sbin/amtape"; private static final String AMTAPEOPT1 = "-otpchanger=vault_changer"; private static final String AMTAPEOPT2 = "-ointeractivity="; private String amtape(String tape) throws Exception { String cmd[] = new String[6]; cmd[0] = AMTAPE; cmd[1] = AMTAPEOPT1; cmd[2] = AMTAPEOPT2; cmd[3] = configuration.AMCONFIG(); cmd[4] = "label"; cmd[5] = tape; System.err.printf("*** FlushOldVaults.amtape(): tape is '%s'\n",tape); Process p = Runtime.getRuntime().exec(cmd); InputStream err = p.getErrorStream(); if (err != null) err.readAllBytes(); if (!p.waitFor(60L, java.util.concurrent.TimeUnit.SECONDS)) { System.err.printf("*** FlushOldVaults.amtape(): process timeout\n"); String kill[] = new String[2]; kill[0] = "/bin/kill"; Long j = new Long(p.pid()); kill[1] = j.toString(); Process killproc = Runtime.getRuntime().exec(kill); killproc.waitFor(); } int status = p.waitFor(); System.err.printf("*** FlushOldVaults.amtape(): status = %d\n",status); if (status != 0) throw new Exception(AMTAPE+" "+AMTAPEOPT1+" "+AMTAPEOPT2+" "+configuration.AMCONFIG()+" label "+tape+": failed"); String tpchanger = amgetconf("CHANGER:vault_changer:tpchanger"); int colon = tpchanger.indexOf(':'); if (colon < 0) { return tpchanger+"/data/"; } else { return tpchanger.substring(colon+1)+"/data/"; } } } > > > > > If it does still hang, what do "lsof -p" and "strace -p" show on the > > amtape process while it's stuck? > > > > Nathan > > > > ---------------------------------------------------------------------------- > > Nathan Stratton Treadway - [email protected] - Mid-Atlantic region > > Ray Ontko & Co. - Software consulting services - http://www.ontko.com/ > > GPG Key: http://www.ontko.com/~nathanst/gpg_key.txt ID: 1023D/ECFB6239 > > Key fingerprint = 6AD8 485E 20B9 5C71 231C 0C32 15F3 ADCD ECFB 6239 > > > > > > > -- Robert Heller -- Cell: 413-658-7953 GV: 978-633-5364 Deepwoods Software -- Custom Software Services http://www.deepsoft.com/ -- Linux Administration Services [email protected] -- Webhosting Services
