home *** CD-ROM | disk | FTP | other *** search
- /************************************************************************/
- /* */
- /* jr .. job repeat. repeat (optionally to kill) current job) */
- /* */
- /* usage: jr [-k] qname */
- /* */
- /* Copyright (c) Vita Services 1990 */
- /* (c) Vita Fibres 1990 1991 */
- /* */
- /************************************************************************/
-
- #include "qbatch.h"
- int fpq = 0;
- int kflag = 0, rflag = 0;
- uid_t uid;
- char *queuename;
- char queue[128];
- char buff [128];
- #include "config.h"
-
-
- main (argc, argv, envp)
- int argc;
- char *argv[], *envp[];
- {
- int c;
- extern char *optarg;
- extern int optind;
- while ((c = getopt (argc, argv, "kv")) != -1)
- switch (c)
- {
- case 'k': kflag = 1;
- break;
- case 'v': q_version();
- case '?': qb_term (-1);
- }
- if (optind >= argc)
- {
- fprintf (stderr, "Usage: jr [-k] qname\n");
- exit (-1);
- }
- queuename = argv[optind];
- strcpy (queue, QUEUEPATH);
- strcat (queue, queuename);
- qb_setterm();
- fpq = open (queue, O_RDWR);
- if (fpq == -1)
- {
- fprintf (stderr, "Invalid queue name: %s\n", queuename);
- qb_term (-1);
- }
- q_lock(fpq);
- read (fpq, &head, sizeof(head));
- if (bad_queue()) qb_exit(-1);
- read (fpq, &entry, sizeof(entry));
- uid = geteuid();
- if (uid != 0 && uid != entry.qe_uid)
- {
- fprintf (stderr, "Must own the job or be super user to repeat or kill\n");
- qb_term (-1);
- }
- if ((head.qh_flags&qh_repeat) == 0)
- {
- head.qh_flags += qh_repeat;
- }
- if (kflag)
- {
- if ((head.qh_flags&qh_kill) == 0)
- {
- head.qh_flags += qh_kill;
- }
- }
- lseek (fpq, 0, SEEK_SET);
- write (fpq, &head, sizeof(head));
- q_unlock(fpq);
- close(fpq); fpq = 0;
- tell_qp();
- qb_term(0);
- }
-