home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 11 Util / 11-Util.zip / IDLE.ZIP / IDLE.C < prev    next >
C/C++ Source or Header  |  1990-10-20  |  2KB  |  79 lines

  1. /****************************************************************************
  2.  *                                                                          *
  3.  *    Idle - A shell environment to place a process into idle priority      *
  4.  *                                                                          *
  5.  *    useage:-  idle <process> <args>                                       *
  6.  *                                                                          *
  7.  *    CopyRight 1990 by J.G. Rozema                                         *
  8.  *                                                                          *
  9.  ****************************************************************************/
  10.  
  11. /*
  12.  
  13.   $Header:   I:/BBSTOOLS/IDLE/VCS/IDLE.C_V   1.2   25 Sep 1990 22:12:34   jgr  $
  14.  
  15.   $Revision:   1.2  $
  16.  
  17.   $Log:   I:/BBSTOOLS/IDLE/VCS/IDLE.C_V  $
  18.  * 
  19.  *    Rev 1.2   25 Sep 1990 22:12:34   jgr
  20.  * Added short description and copyright notice.
  21.  * 
  22.  * 
  23.  *    Rev 1.1   11 Jul 1990 03:31:46   jgr
  24.  * Modified the command line processing so that it can now pass parameters to
  25.  * the child process.  Ability to set the delta is also available by the command
  26.  * line now.
  27.  * 
  28.  *    Rev 1.0   21 Jun 1990 01:00:26   jgr
  29.  * Initial revision.
  30.  
  31.  
  32. */
  33.  
  34.  
  35. #define INCL_BASE
  36.  
  37. #include <stdlib.h>
  38. #include <stdio.h>
  39. #include <process.h>
  40. #include <string.h>
  41. #include <os2.h>
  42.  
  43. char command[1024];
  44.  
  45. void main(int argc, char **argv)
  46. {
  47.  
  48.     SHORT Delta;
  49.     int x;
  50.  
  51.     command[0]=0;
  52.  
  53.     if( argc < 2 ){
  54.           printf("Idle - Run sessions at idle Priority\n");
  55.           printf("Copyright (c) 1990 by J.G. Rozema\n");
  56.         printf("Usage: Idle [-delta] <program>\n");
  57.         exit(0);
  58.     }
  59.      Delta=0;
  60.  
  61.      if (argv[1][0]=='-') {
  62.         Delta=atoi(&argv[1][1]);
  63.         DosSetPrty(PRTYS_PROCESSTREE,PRTYC_IDLETIME,Delta,NULL);
  64.         for (x=2; x<argc; x++) {
  65.             strcat(command,argv[x]);
  66.             strcat(command," ");
  67.         }
  68.      }
  69.      else {
  70.         DosSetPrty(PRTYS_PROCESSTREE,PRTYC_IDLETIME,-31,NULL);
  71.         for (x=1; x<argc; x++) {
  72.             strcat(command,argv[x]);
  73.             strcat(command," ");
  74.         }
  75.     }
  76.       system (command);
  77. }
  78.  
  79.