diff options
author | Jonathan Cowper-Andrewes <Jonathan.Ca@Sun.COM> | 2008-11-05 16:54:46 +0000 |
---|---|---|
committer | Jonathan Cowper-Andrewes <Jonathan.Ca@Sun.COM> | 2008-11-05 16:54:46 +0000 |
commit | d03e4ae852e122903f8876fb2ba7df676722d799 (patch) | |
tree | d54925071fb1cf2224124dfd4ee65c165cade5b1 /usr/src/cmd/print/bsd-sysv-commands/cancel.c | |
parent | f7f8e53d2c63138c2a1d03ff508ee4e91987d8b9 (diff) | |
download | illumos-joyent-d03e4ae852e122903f8876fb2ba7df676722d799.tar.gz |
6724477 cancel segfaults when running cancel <printer>
Diffstat (limited to 'usr/src/cmd/print/bsd-sysv-commands/cancel.c')
-rw-r--r-- | usr/src/cmd/print/bsd-sysv-commands/cancel.c | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/usr/src/cmd/print/bsd-sysv-commands/cancel.c b/usr/src/cmd/print/bsd-sysv-commands/cancel.c index 8d54c08a47..82996e4630 100644 --- a/usr/src/cmd/print/bsd-sysv-commands/cancel.c +++ b/usr/src/cmd/print/bsd-sysv-commands/cancel.c @@ -27,7 +27,6 @@ /* $Id: cancel.c 147 2006-04-25 16:51:06Z njacobs $ */ -#pragma ident "%Z%%M% %I% %E% SMI" #include <stdio.h> #include <stdlib.h> @@ -170,15 +169,22 @@ main(int ac, char *av[]) } if (jobs != NULL && *jobs != NULL) { - char jobid[32]; - char *jid; - - snprintf(jobid, sizeof (jobid), "%u", - papiJobGetId(*jobs)); - - jid = jobid; - exit_code = berkeley_cancel_request(svc, - stdout, printer, 1, &jid); + char *mesg = "cancelled"; + id = papiJobGetId(*jobs); + + status = papiJobCancel(svc, + printer, id); + + if (status == PAPI_NOT_AUTHORIZED) { + mesg = papiStatusString(status); + exit_code = 1; + } else if (status != PAPI_OK) { + mesg = verbose_papi_message( + svc, status); + exit_code = 1; + } + fprintf(OUT, "%s-%d: %s\n", printer, + id, mesg); } papiJobListFree(jobs); |