Mt Xia: Technical Consulting Group

Business Continuity / Disaster Recovery / High Availability
Data Center Automation / Audit Response / Audit Compliance

-
Current Location
-

css
  Downloads
    C-Code

-

digg Digg this page
del.icio.us Post to del.icio.us
Slashdot Slashdot it!


Business Web Site Hosting
$3.99 / month includes Tools,
Shopping Cart, Site Builder

www.siteox.com

FREE Domain Registration
included with Web Site Hosting
Tools, Social Networking, Blog

www.siteox.com

setlinuxpri.c C-Language Source Code

/* Set a process to a constant and permanent priority

   Name:   setlinuxpri.c

   Compile using:  gcc -o setlinuxpri setlinuxpri.c
                   chown root setlinuxpri
                   chmod 0500 setlinuxpri

   Usage:  setlinuxpri -p ProcessID -P Priority

*/

#include 
#include 
int setpriority(int which, id_t who, int value);
int getopt (ArgumentC,  ArgumentV,  OptionString);
int ArgumentC;
char *const ArgumentV [ ];
const char *OptionString;

extern int  optind;
extern int  optopt;
extern int  opterr;
extern char * optarg;

/* ############################################################# */

int main(int argc, char** argv)
{
        int arg;
        int ProcessID;
        int Priority;
        int out;

        ProcessID = -1;
        Priority = 60;

        while (arg!=EOF)
        {
                arg=getopt(argc, argv, "p:P:");
                switch(arg)
                {
/* Set the process id number */
                case 'p':
                        ProcessID=atoi(optarg);
                        break;
/* Set the priority number */
                case 'P':
                        Priority=atoi(optarg);   /* Set the priority */
                        break;
                case '?':
                        exit(usage());
                }
        }

        if ( ProcessID >= 0 ) {
            out = setpriority ( PRIO_PROCESS, ProcessID, Priority);
        } else {
          printf("setlinuxpri: -p option is required\n");
          exit(usage());
        }
}

/* ################################################################ */
/* usage */

int usage()
{
    printf("\nSyntax: setlinuxpri -p ProcessID [-P Priority]\n");
    printf("        Maximum Priority =   1\n");
    printf("        Default Priority =  60\n");
    printf("        Minimum Priority = 254\n");
    return(1);
}

-
setlinuxpri.c
-
 


FREE Domain Registration
included with Web Site Hosting
Tools, Social Networking, Blog

www.siteox.com

Business Web Site Hosting
$3.99 / month includes Tools,
Shopping Cart, Site Builder

www.siteox.com