Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

undefined reference to 'getpri'

Status
Not open for further replies.

logic4fun

Programmer
Apr 24, 2003
85
US
Hi all,
I am trying to port one of my C: application from AIX to LINUX and this is a new linux box..and when i try to compile on LINUX for the following chunk of code it throws the afore said error.."undefined reference to 'getpri'" and the same code compiles very well in the AIX platform.

if (wrkpid != getpid() && (getpri(getpid()) != -1 || errno != ESRCH)) {
printf("Program already running - cancelling run %ld for %ld\n", getpid(), wrkpid);
exit(0);
}

i wanted to know am i missing any library in my box or can we use getpri() on linux box if we cannot any alternative function which checks for the running processes in the memory instance..
I tried using getpriority() doesnt really help as it returns the nice value. where as getpri() returns the scheduling priority.

THANKS in advance

Logic4fun
 
getpri() seems to be an AIX only thing - getpriority() on Linux seems to do the same thing.

Though I have to say, I fail to see the point of
Code:
 (getpri(getpid()) != -1 || errno != ESRCH)
since as far as I can tell, it always evaluates to true

getpid() returns the current process ID, which means that getpri() would always be successful and therefore the
Code:
!= -1
test would always be true.

Code:
if (wrkpid != getpid() ) {
    printf("Program already running - cancelling run %ld for %ld\n", getpid(), wrkpid);
    exit(0);
}
Seems to be equivalent.
 
I dont think it always returns a -1 becoz i tried to run one more copy of my program while one is already running then it returns 60/61 whatever the priority and the above condition fails and enters into the loop on AIX box.
 
I'm suggesting that it never returns -1, because a process should always be able to get the priority of itself.

Where does wrkpid come from?
 
hi salem

wrkpid = getpid(). he loads getpid() into a struct and pulls that value and assigns to wrkpid. I am sorry if i am not clear..as i myself know little about it..coz i am trying to port this application..and the person who wrote..No longer here...:-(

thanks for ur help
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top