home *** CD-ROM | disk | FTP | other *** search
- /************************************************************************/
- /* */
- /* qh .. Queue halt. suspend processing of current job in this queue. */
- /* */
- /* usage: qh qname */
- /* */
- /* Copyright (c) Vita Services 1990 */
- /* (c) Vita Fibres 1990 1991 */
- /* */
- /************************************************************************/
-
- #include "qbatch.h"
- int fpq = 0;
- uid_t uid;
- char *queuename;
- char queue[128];
- char buff[128];
- #include "config.h"
-
-
- main (argc, argv, envp)
- int argc;
- char *argv[],
- *envp[];
- {
- if (argc == 1)
- {
- puts ("Usage qh queuename");
- qb_term (0);
- }
- if (strcmp(argv[1], "-v") == 0) q_version();
- queuename = argv[1];
- 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);
- }
- uid = getuid ();
- if (uid != 0)
- {
- fprintf (stderr, "Must be super user to halt a queue\n");
- qb_term (-1);
- }
- q_lock(fpq);
- read (fpq, &head, sizeof (head));
- if (bad_queue()) qb_exit(-1);
- if (head.qh_pid == 0)
- {
- fprintf (stderr, "Queue %s is idle\n", queuename);
- qb_term (-1);
- }
- if ((head.qh_flags & qh_halt) == 0)
- {
- head.qh_flags += qh_halt;
- }
- else
- {
- fprintf (stderr, "Queue %s is already halted\n", queuename);
- qb_term (-1);
- }
- lseek (fpq, 0, SEEK_SET);
- write (fpq, &head, sizeof(head));
- q_unlock(fpq);
- close (fpq);
- fpq = 0;
- tell_qp();
- exit (0);
- }
-