Mt Xia: Technical Consulting Group
Business Continuity / Disaster Recovery / High Availability Data Center Automation / Audit Response / Audit Compliance
/* 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); }