Find the answer to your Linux question:
Results 1 to 2 of 2
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    Handling alarm signal in system call implementation

    I am trying to implement a system call in linux that performs a specifc functionality after some seconds have elapsed. For this pupose i use sys_alarm() in my system call and pass to it the number of seconds i want the process to wait. When the alarm goes off i call a handler function that is registered using sys_signal(). The problem is that whenever i invoke the system call through a user program, the user program gets stuck...Could you please go through the code and check what is missing ?

    #include <linux/linkage.h> //for linking a system call
    #include <linux/kernel.h>

    volatile int keep_going = 1;

    void alarm_handler(int signal)
    keep_going = 0;


    asmlinkage long sys_myservice(int arg) {

    int delay=20;
    sys_signal(SIGALRM, alarm_handler);

    while (keep_going){

    //do nothing

    //write functionality here

    return 1;


  2. #2
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    I can be found either 40 miles west of Chicago, in Chicago, or in a galaxy far, far away.
    What do you mean by "whenever i invoke the system call through a user program"? Are you trying to invoke the call directly? Have you written and installed a kernel module to handle the call from the user?
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts