c - How can i perform my exe file from boot.local -


i've written code boosting priority of process on opensuse 12.2 system.

#include <stdio.h> #include <sched.h> #include <unistd.h>  int printusage(void) {     printf("\nusage:\nboostprio [pid] [priority: (0-99)] [policy: ff:rr:oth]\n");     exit (1); }  int main (int argc , char *argv[]) {     int pid = -1 ;     int pri;      struct sched_param param;      if(argc != 4 ){         printf("\nargument miss match !!");         printusage();         return -1;         }      if((strcmp(argv[1],"-h" ) == 0) || (strcmp(argv[1],"--help") == 0))         printusage();      pid = atoi(argv[1]);      if(pid <= 0){         printf("\npid not correct!!\n");         return -1;     }     pri = atoi(argv[2]);     if((pri > 99) || (pri < 0)){         printf("\npriority value not valid !!\n");         return -1;         }     param.sched_priority = pri;      if(strcmp(argv[3],"ff") == 0)          sched_setscheduler((pid_t)pid, sched_fifo, &param);     else if(strcmp(argv[3],"rr") == 0)          sched_setscheduler((pid_t)pid, sched_rr, &param);     else if(strcmp(argv[3],"oth") == 0)                  sched_setscheduler((pid_t)pid, sched_other, &param);     else{         printf("\ninvalid scheduling policy type!!\n");         printusage();         }      return 0; } 

and write bash script shell.sh invoking boostprio binary file

#!/bin/sh  pid=`ps -ef | grep "sshd -p 911" |head -1 | awk '{print $2}'`  /sbin/boostprio $pid 95 rr  if [ "$?" == 0 ];     logger -t "emergency shell activated." else     logger -t "emergency shell not activated !!" fi 

although new sshd -p 911 starting @ boot, boostprio exe doesnt work , doesnt boost priority of sshd. still ordinary priority. here image file seen on putty

enter image description here

further more, if invoke shell.sh script manually on command prompt instead of boot.local, boostprio works !

here printscr

enter image description here

consequently, /usr/sbin/boostprio exe doesnt work when invoked /etc/init.d/boot.local

moreover printed sched_setscheduler() func in boostprio.c , failed returning 255 think actual problem. dont know how figure out ?

looks have sincronization problems. (-:

on opensuse 12.2 (and others) service statup assincronous and, because of cant rely on boot.local this. in opinion best way write init.d script depends on sshd service (or $all services) and, on startup wait little bit (just in case) , then, try change sshd priority

look @ script in /etc/init.d/skeleton reference , write new 1 changes in header;

something like:

### begin init info # provides:          sshprio # required-start:    $all 

or...

### begin init info # provides:          sshprio # required-start:    sshd 

Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -