home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / misc / volume25 / QBATCH / part01 / src / qw.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-11-04  |  1.5 KB  |  50 lines

  1. /************************************************************************/  
  2. /*                                                                      */
  3. /* qw .. queue wait. wait till queue is idle.                           */
  4. /*                                                                      */
  5. /*      usage: qw qname                                      */
  6. /*                                                                      */
  7. /*   Copyright (c) Vita Services 1990                                   */
  8. /*             (c) Vita Fibres   1990 1991                              */
  9. /*                                                                      */
  10. /************************************************************************/
  11.  
  12. #include "qbatch.h"
  13. int fpq = 0;
  14. int kflag = 0, rflag = 0;
  15. char *queuename;
  16. char queue[128];
  17. char buff [128];                            
  18. #include "config.h"
  19.                             
  20. main (argc, argv, envp)
  21. int argc;
  22. char *argv[], *envp[];
  23. {
  24.  
  25.     if (argc != 2)
  26.     {
  27.         fprintf(stderr, "Usage : qw <qname>\n");
  28.         exit (-1);
  29.     }
  30.     if (strcmp (argv[1], "-v") == 0) q_version();
  31.     queuename = argv[1];
  32.     strcpy (queue, QUEUEPATH);
  33.     strcat (queue, queuename);
  34.     qb_setterm();
  35.     do
  36.     {
  37.         fpq = open (queue, O_RDWR);
  38.         q_lock(fpq);
  39.         read  (fpq, &head, sizeof(head));
  40.     if (bad_queue()) qb_exit(-1);
  41.         q_unlock(fpq);
  42.         close (fpq);fpq = 0;
  43.         if (head.qh_pid == 0) break;
  44.         sleep (30);
  45.     }
  46.     while (head.qh_pid != 0);
  47.  
  48.     qb_term (0);
  49. }
  50.