I'm writing code that uses sched_setaffinity, which requires kernel 2.5.8 or later. I've been trying to find out if these things are possible:
I guess my question is, how do you use new kernel functions safely, without breaking the entire application when using an older system?
using function keyword : A function in linux can be declared by using keyword function before the name of the function. Different statements can be separated by a semicolon or a new line.
ctrl+z stops the process and returns you to the current shell. You can now type fg to continue process, or type bg to continue the process in the background.
Use dlopen()
with NULL
as the filename, and dlsym()
the function you want to use. If the dlsym()
succeeds, call the function through the function pointer that was returned.
Are you trying to get your program to link or to run? You can invoke the system call directly via the glibc syscall()
function without needing a recent C library. Obviously it's going to fail on earlier systems without support (a quick test shows the kernel returns -1 == ENOSYS for unimplemented syscall numbers), so you will need to test for that.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With