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

setpri.c C-Language Source Code

/* Set a process to a constant and permanent priority

   Name:   setpri.c

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

   Usage:  setpri -p ProcessID -P Priority

*/

#include 

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

int main(int argc, char** argv)
{
        int arg;
        pid_t 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 = setpri ( ProcessID, Priority);
        } else {
          printf("setpri: -p option is required\n");
          exit(usage());
        }
}

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

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

-
setpri.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