Catch which user sends kill signal












2














Say I'm running some script that just sleeps, and another user with admin rights tries to kill my script using pkill. How can I catch which user sent that signal to my process, if such a thing is possible?



I know that something like kill -9 <my_script> won't allow me to catch anything, as we can't catch or do anything with SIGKILL.










share|improve this question






















  • Do you have admin (root) access to the machine? Is the machine running linux?
    – icarus
    Dec 18 at 16:52










  • Root access? No. Running linux? Yes.
    – blacksite
    Dec 18 at 17:32










  • OK, then my solution monitoring the system calls with ftrace will not work.
    – icarus
    Dec 18 at 18:12
















2














Say I'm running some script that just sleeps, and another user with admin rights tries to kill my script using pkill. How can I catch which user sent that signal to my process, if such a thing is possible?



I know that something like kill -9 <my_script> won't allow me to catch anything, as we can't catch or do anything with SIGKILL.










share|improve this question






















  • Do you have admin (root) access to the machine? Is the machine running linux?
    – icarus
    Dec 18 at 16:52










  • Root access? No. Running linux? Yes.
    – blacksite
    Dec 18 at 17:32










  • OK, then my solution monitoring the system calls with ftrace will not work.
    – icarus
    Dec 18 at 18:12














2












2








2







Say I'm running some script that just sleeps, and another user with admin rights tries to kill my script using pkill. How can I catch which user sent that signal to my process, if such a thing is possible?



I know that something like kill -9 <my_script> won't allow me to catch anything, as we can't catch or do anything with SIGKILL.










share|improve this question













Say I'm running some script that just sleeps, and another user with admin rights tries to kill my script using pkill. How can I catch which user sent that signal to my process, if such a thing is possible?



I know that something like kill -9 <my_script> won't allow me to catch anything, as we can't catch or do anything with SIGKILL.







kill signals






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Dec 18 at 16:24









blacksite

1113




1113












  • Do you have admin (root) access to the machine? Is the machine running linux?
    – icarus
    Dec 18 at 16:52










  • Root access? No. Running linux? Yes.
    – blacksite
    Dec 18 at 17:32










  • OK, then my solution monitoring the system calls with ftrace will not work.
    – icarus
    Dec 18 at 18:12


















  • Do you have admin (root) access to the machine? Is the machine running linux?
    – icarus
    Dec 18 at 16:52










  • Root access? No. Running linux? Yes.
    – blacksite
    Dec 18 at 17:32










  • OK, then my solution monitoring the system calls with ftrace will not work.
    – icarus
    Dec 18 at 18:12
















Do you have admin (root) access to the machine? Is the machine running linux?
– icarus
Dec 18 at 16:52




Do you have admin (root) access to the machine? Is the machine running linux?
– icarus
Dec 18 at 16:52












Root access? No. Running linux? Yes.
– blacksite
Dec 18 at 17:32




Root access? No. Running linux? Yes.
– blacksite
Dec 18 at 17:32












OK, then my solution monitoring the system calls with ftrace will not work.
– icarus
Dec 18 at 18:12




OK, then my solution monitoring the system calls with ftrace will not work.
– icarus
Dec 18 at 18:12










2 Answers
2






active

oldest

votes


















3














Yes, this is possible, albeit perhaps not from a script. For this to work, you need to set your signal handler up using sigaction with the SA_SIGINFO flag, and provide a handler with a signature identical to



void handler(int sig, siginfo_t *info, void *ucontext)


When it is invoked to handle a signal, the siginfo_t pointer it receives as its second argument will contain, among other pieces of information, the process identifier of the sending process (info->si_pid), and the read user identifier of the sending process (info->si_uid). These are filled in for signals sent using kill or sigqueue.



Implementing this in Python would require a fair amount of work, since the signal module doesn’t provide a way of accessing the siginfo_t structure.






share|improve this answer























  • Hmmm. I see how this could get tricky for a shell script with many processes created therein... So I'd have to add this logic to each process, basically? How could I do this handler logic in just the "runner" shell script itself? I'm fairly sure I could figure out how to handle this in Python (all of my processes in this shell script are from Python), but want to catch anyone trying to kill my topmost shell script.
    – blacksite
    Dec 18 at 16:35










  • Ah yes, I got a bit carried away and forgot this was for a script. I imagine this is possible from Python, but I don’t think it is from a shell script.
    – Stephen Kitt
    Dec 18 at 16:38



















1














bash + ctypes.sh



Just for fun, using @StephenKitt 's solution, here's an example in bash, using the bash plugin ctypes.sh (which must be be compiled and installed in /usr/local for this example).



Sadly, both structures sigaction and siginfo_t are too complex for ctypes.sh's builtin struct command to work. Those structures have thus to be manually defined. This is a quite annoying chore, and it's non-portable (both for OS and for architecture). This example assumes Linux >= 4.6 (because of info->si_pkey) on x86_64 architecture.



#!/bin/bash

. /usr/local/bin/ctypes.sh || exit 2

handler () {
local -a info=(int int int int uint32 uint32 int int64 int64 int64 int pointer int int pointer long int short pointer pointer int pointer int unsigned)
unpack $3 info

echo ''
echo "handler($2, info={${info[@]}}, $4);"
echo -- handling signal $2 --
echo "info->si_pid=${info[4]}"
echo "info->si_uid=${info[5]}"
return
}
callback -n handler handler void int pointer pointer

SIGUSR2=12
SA_SIGINFO=4

act=(
$handler
long:0 long:0 long:0 long:0 long:0 long:0 long:0 long:0 long:0 long:0 long:0 long:0 long:0 long:0 long:0 long:0
int:$SA_SIGINFO
pointer:0
)
sizeof_act=$(( 8 + 16 * 8 + 4 + 8 ))

dlcall -n pact -r pointer malloc $sizeof_act
[ $pact != pointer:0 ] || exit 1
pack $pact act

dlcall -n ret -r int sigaction int:$SIGUSR2 $pact pointer:0
[ $ret = int:0 ] || exit 1

echo "sigaction(SIGUSR2, act={${act[@]}}, NULL) = $ret"

echo ''
echo run this: kill -$SIGUSR2 $$
sleep 99


Execution:



term1:



$ ./siginfo.bash 
sigaction(SIGUSR2, act={pointer:0x7ff26f0d3010 long:0 long:0 long:0 long:0 long:0 long:0 long:0 long:0 long:0 long:0 long:0 long:0 long:0 long:0 long:0 long:0 int:4 pointer:0}, NULL) = int:0

run this: kill -12 24250


term2:



$ echo $$
21864
$ id -u
1000
$ kill -12 24250
$


result in term1:



handler(int:12, info={int:12 int:0 int:0 int:0 uint32:21864 uint32:1000 int:0 int64:0 int64:0 int64:0 int:0 pointer:0 int:0 int:0 pointer:0 long:0 int:0 short:0 pointer:0 pointer:0 int:0 pointer:0 int:0 unsigned:0}, pointer:0x7fff4583a500);
-- handling signal int:12 --
info->si_pid=uint32:21864
info->si_uid=uint32:1000





share|improve this answer





















    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "106"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f489717%2fcatch-which-user-sends-kill-signal%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    3














    Yes, this is possible, albeit perhaps not from a script. For this to work, you need to set your signal handler up using sigaction with the SA_SIGINFO flag, and provide a handler with a signature identical to



    void handler(int sig, siginfo_t *info, void *ucontext)


    When it is invoked to handle a signal, the siginfo_t pointer it receives as its second argument will contain, among other pieces of information, the process identifier of the sending process (info->si_pid), and the read user identifier of the sending process (info->si_uid). These are filled in for signals sent using kill or sigqueue.



    Implementing this in Python would require a fair amount of work, since the signal module doesn’t provide a way of accessing the siginfo_t structure.






    share|improve this answer























    • Hmmm. I see how this could get tricky for a shell script with many processes created therein... So I'd have to add this logic to each process, basically? How could I do this handler logic in just the "runner" shell script itself? I'm fairly sure I could figure out how to handle this in Python (all of my processes in this shell script are from Python), but want to catch anyone trying to kill my topmost shell script.
      – blacksite
      Dec 18 at 16:35










    • Ah yes, I got a bit carried away and forgot this was for a script. I imagine this is possible from Python, but I don’t think it is from a shell script.
      – Stephen Kitt
      Dec 18 at 16:38
















    3














    Yes, this is possible, albeit perhaps not from a script. For this to work, you need to set your signal handler up using sigaction with the SA_SIGINFO flag, and provide a handler with a signature identical to



    void handler(int sig, siginfo_t *info, void *ucontext)


    When it is invoked to handle a signal, the siginfo_t pointer it receives as its second argument will contain, among other pieces of information, the process identifier of the sending process (info->si_pid), and the read user identifier of the sending process (info->si_uid). These are filled in for signals sent using kill or sigqueue.



    Implementing this in Python would require a fair amount of work, since the signal module doesn’t provide a way of accessing the siginfo_t structure.






    share|improve this answer























    • Hmmm. I see how this could get tricky for a shell script with many processes created therein... So I'd have to add this logic to each process, basically? How could I do this handler logic in just the "runner" shell script itself? I'm fairly sure I could figure out how to handle this in Python (all of my processes in this shell script are from Python), but want to catch anyone trying to kill my topmost shell script.
      – blacksite
      Dec 18 at 16:35










    • Ah yes, I got a bit carried away and forgot this was for a script. I imagine this is possible from Python, but I don’t think it is from a shell script.
      – Stephen Kitt
      Dec 18 at 16:38














    3












    3








    3






    Yes, this is possible, albeit perhaps not from a script. For this to work, you need to set your signal handler up using sigaction with the SA_SIGINFO flag, and provide a handler with a signature identical to



    void handler(int sig, siginfo_t *info, void *ucontext)


    When it is invoked to handle a signal, the siginfo_t pointer it receives as its second argument will contain, among other pieces of information, the process identifier of the sending process (info->si_pid), and the read user identifier of the sending process (info->si_uid). These are filled in for signals sent using kill or sigqueue.



    Implementing this in Python would require a fair amount of work, since the signal module doesn’t provide a way of accessing the siginfo_t structure.






    share|improve this answer














    Yes, this is possible, albeit perhaps not from a script. For this to work, you need to set your signal handler up using sigaction with the SA_SIGINFO flag, and provide a handler with a signature identical to



    void handler(int sig, siginfo_t *info, void *ucontext)


    When it is invoked to handle a signal, the siginfo_t pointer it receives as its second argument will contain, among other pieces of information, the process identifier of the sending process (info->si_pid), and the read user identifier of the sending process (info->si_uid). These are filled in for signals sent using kill or sigqueue.



    Implementing this in Python would require a fair amount of work, since the signal module doesn’t provide a way of accessing the siginfo_t structure.







    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Dec 18 at 16:49

























    answered Dec 18 at 16:32









    Stephen Kitt

    164k24365444




    164k24365444












    • Hmmm. I see how this could get tricky for a shell script with many processes created therein... So I'd have to add this logic to each process, basically? How could I do this handler logic in just the "runner" shell script itself? I'm fairly sure I could figure out how to handle this in Python (all of my processes in this shell script are from Python), but want to catch anyone trying to kill my topmost shell script.
      – blacksite
      Dec 18 at 16:35










    • Ah yes, I got a bit carried away and forgot this was for a script. I imagine this is possible from Python, but I don’t think it is from a shell script.
      – Stephen Kitt
      Dec 18 at 16:38


















    • Hmmm. I see how this could get tricky for a shell script with many processes created therein... So I'd have to add this logic to each process, basically? How could I do this handler logic in just the "runner" shell script itself? I'm fairly sure I could figure out how to handle this in Python (all of my processes in this shell script are from Python), but want to catch anyone trying to kill my topmost shell script.
      – blacksite
      Dec 18 at 16:35










    • Ah yes, I got a bit carried away and forgot this was for a script. I imagine this is possible from Python, but I don’t think it is from a shell script.
      – Stephen Kitt
      Dec 18 at 16:38
















    Hmmm. I see how this could get tricky for a shell script with many processes created therein... So I'd have to add this logic to each process, basically? How could I do this handler logic in just the "runner" shell script itself? I'm fairly sure I could figure out how to handle this in Python (all of my processes in this shell script are from Python), but want to catch anyone trying to kill my topmost shell script.
    – blacksite
    Dec 18 at 16:35




    Hmmm. I see how this could get tricky for a shell script with many processes created therein... So I'd have to add this logic to each process, basically? How could I do this handler logic in just the "runner" shell script itself? I'm fairly sure I could figure out how to handle this in Python (all of my processes in this shell script are from Python), but want to catch anyone trying to kill my topmost shell script.
    – blacksite
    Dec 18 at 16:35












    Ah yes, I got a bit carried away and forgot this was for a script. I imagine this is possible from Python, but I don’t think it is from a shell script.
    – Stephen Kitt
    Dec 18 at 16:38




    Ah yes, I got a bit carried away and forgot this was for a script. I imagine this is possible from Python, but I don’t think it is from a shell script.
    – Stephen Kitt
    Dec 18 at 16:38













    1














    bash + ctypes.sh



    Just for fun, using @StephenKitt 's solution, here's an example in bash, using the bash plugin ctypes.sh (which must be be compiled and installed in /usr/local for this example).



    Sadly, both structures sigaction and siginfo_t are too complex for ctypes.sh's builtin struct command to work. Those structures have thus to be manually defined. This is a quite annoying chore, and it's non-portable (both for OS and for architecture). This example assumes Linux >= 4.6 (because of info->si_pkey) on x86_64 architecture.



    #!/bin/bash

    . /usr/local/bin/ctypes.sh || exit 2

    handler () {
    local -a info=(int int int int uint32 uint32 int int64 int64 int64 int pointer int int pointer long int short pointer pointer int pointer int unsigned)
    unpack $3 info

    echo ''
    echo "handler($2, info={${info[@]}}, $4);"
    echo -- handling signal $2 --
    echo "info->si_pid=${info[4]}"
    echo "info->si_uid=${info[5]}"
    return
    }
    callback -n handler handler void int pointer pointer

    SIGUSR2=12
    SA_SIGINFO=4

    act=(
    $handler
    long:0 long:0 long:0 long:0 long:0 long:0 long:0 long:0 long:0 long:0 long:0 long:0 long:0 long:0 long:0 long:0
    int:$SA_SIGINFO
    pointer:0
    )
    sizeof_act=$(( 8 + 16 * 8 + 4 + 8 ))

    dlcall -n pact -r pointer malloc $sizeof_act
    [ $pact != pointer:0 ] || exit 1
    pack $pact act

    dlcall -n ret -r int sigaction int:$SIGUSR2 $pact pointer:0
    [ $ret = int:0 ] || exit 1

    echo "sigaction(SIGUSR2, act={${act[@]}}, NULL) = $ret"

    echo ''
    echo run this: kill -$SIGUSR2 $$
    sleep 99


    Execution:



    term1:



    $ ./siginfo.bash 
    sigaction(SIGUSR2, act={pointer:0x7ff26f0d3010 long:0 long:0 long:0 long:0 long:0 long:0 long:0 long:0 long:0 long:0 long:0 long:0 long:0 long:0 long:0 long:0 int:4 pointer:0}, NULL) = int:0

    run this: kill -12 24250


    term2:



    $ echo $$
    21864
    $ id -u
    1000
    $ kill -12 24250
    $


    result in term1:



    handler(int:12, info={int:12 int:0 int:0 int:0 uint32:21864 uint32:1000 int:0 int64:0 int64:0 int64:0 int:0 pointer:0 int:0 int:0 pointer:0 long:0 int:0 short:0 pointer:0 pointer:0 int:0 pointer:0 int:0 unsigned:0}, pointer:0x7fff4583a500);
    -- handling signal int:12 --
    info->si_pid=uint32:21864
    info->si_uid=uint32:1000





    share|improve this answer


























      1














      bash + ctypes.sh



      Just for fun, using @StephenKitt 's solution, here's an example in bash, using the bash plugin ctypes.sh (which must be be compiled and installed in /usr/local for this example).



      Sadly, both structures sigaction and siginfo_t are too complex for ctypes.sh's builtin struct command to work. Those structures have thus to be manually defined. This is a quite annoying chore, and it's non-portable (both for OS and for architecture). This example assumes Linux >= 4.6 (because of info->si_pkey) on x86_64 architecture.



      #!/bin/bash

      . /usr/local/bin/ctypes.sh || exit 2

      handler () {
      local -a info=(int int int int uint32 uint32 int int64 int64 int64 int pointer int int pointer long int short pointer pointer int pointer int unsigned)
      unpack $3 info

      echo ''
      echo "handler($2, info={${info[@]}}, $4);"
      echo -- handling signal $2 --
      echo "info->si_pid=${info[4]}"
      echo "info->si_uid=${info[5]}"
      return
      }
      callback -n handler handler void int pointer pointer

      SIGUSR2=12
      SA_SIGINFO=4

      act=(
      $handler
      long:0 long:0 long:0 long:0 long:0 long:0 long:0 long:0 long:0 long:0 long:0 long:0 long:0 long:0 long:0 long:0
      int:$SA_SIGINFO
      pointer:0
      )
      sizeof_act=$(( 8 + 16 * 8 + 4 + 8 ))

      dlcall -n pact -r pointer malloc $sizeof_act
      [ $pact != pointer:0 ] || exit 1
      pack $pact act

      dlcall -n ret -r int sigaction int:$SIGUSR2 $pact pointer:0
      [ $ret = int:0 ] || exit 1

      echo "sigaction(SIGUSR2, act={${act[@]}}, NULL) = $ret"

      echo ''
      echo run this: kill -$SIGUSR2 $$
      sleep 99


      Execution:



      term1:



      $ ./siginfo.bash 
      sigaction(SIGUSR2, act={pointer:0x7ff26f0d3010 long:0 long:0 long:0 long:0 long:0 long:0 long:0 long:0 long:0 long:0 long:0 long:0 long:0 long:0 long:0 long:0 int:4 pointer:0}, NULL) = int:0

      run this: kill -12 24250


      term2:



      $ echo $$
      21864
      $ id -u
      1000
      $ kill -12 24250
      $


      result in term1:



      handler(int:12, info={int:12 int:0 int:0 int:0 uint32:21864 uint32:1000 int:0 int64:0 int64:0 int64:0 int:0 pointer:0 int:0 int:0 pointer:0 long:0 int:0 short:0 pointer:0 pointer:0 int:0 pointer:0 int:0 unsigned:0}, pointer:0x7fff4583a500);
      -- handling signal int:12 --
      info->si_pid=uint32:21864
      info->si_uid=uint32:1000





      share|improve this answer
























        1












        1








        1






        bash + ctypes.sh



        Just for fun, using @StephenKitt 's solution, here's an example in bash, using the bash plugin ctypes.sh (which must be be compiled and installed in /usr/local for this example).



        Sadly, both structures sigaction and siginfo_t are too complex for ctypes.sh's builtin struct command to work. Those structures have thus to be manually defined. This is a quite annoying chore, and it's non-portable (both for OS and for architecture). This example assumes Linux >= 4.6 (because of info->si_pkey) on x86_64 architecture.



        #!/bin/bash

        . /usr/local/bin/ctypes.sh || exit 2

        handler () {
        local -a info=(int int int int uint32 uint32 int int64 int64 int64 int pointer int int pointer long int short pointer pointer int pointer int unsigned)
        unpack $3 info

        echo ''
        echo "handler($2, info={${info[@]}}, $4);"
        echo -- handling signal $2 --
        echo "info->si_pid=${info[4]}"
        echo "info->si_uid=${info[5]}"
        return
        }
        callback -n handler handler void int pointer pointer

        SIGUSR2=12
        SA_SIGINFO=4

        act=(
        $handler
        long:0 long:0 long:0 long:0 long:0 long:0 long:0 long:0 long:0 long:0 long:0 long:0 long:0 long:0 long:0 long:0
        int:$SA_SIGINFO
        pointer:0
        )
        sizeof_act=$(( 8 + 16 * 8 + 4 + 8 ))

        dlcall -n pact -r pointer malloc $sizeof_act
        [ $pact != pointer:0 ] || exit 1
        pack $pact act

        dlcall -n ret -r int sigaction int:$SIGUSR2 $pact pointer:0
        [ $ret = int:0 ] || exit 1

        echo "sigaction(SIGUSR2, act={${act[@]}}, NULL) = $ret"

        echo ''
        echo run this: kill -$SIGUSR2 $$
        sleep 99


        Execution:



        term1:



        $ ./siginfo.bash 
        sigaction(SIGUSR2, act={pointer:0x7ff26f0d3010 long:0 long:0 long:0 long:0 long:0 long:0 long:0 long:0 long:0 long:0 long:0 long:0 long:0 long:0 long:0 long:0 int:4 pointer:0}, NULL) = int:0

        run this: kill -12 24250


        term2:



        $ echo $$
        21864
        $ id -u
        1000
        $ kill -12 24250
        $


        result in term1:



        handler(int:12, info={int:12 int:0 int:0 int:0 uint32:21864 uint32:1000 int:0 int64:0 int64:0 int64:0 int:0 pointer:0 int:0 int:0 pointer:0 long:0 int:0 short:0 pointer:0 pointer:0 int:0 pointer:0 int:0 unsigned:0}, pointer:0x7fff4583a500);
        -- handling signal int:12 --
        info->si_pid=uint32:21864
        info->si_uid=uint32:1000





        share|improve this answer












        bash + ctypes.sh



        Just for fun, using @StephenKitt 's solution, here's an example in bash, using the bash plugin ctypes.sh (which must be be compiled and installed in /usr/local for this example).



        Sadly, both structures sigaction and siginfo_t are too complex for ctypes.sh's builtin struct command to work. Those structures have thus to be manually defined. This is a quite annoying chore, and it's non-portable (both for OS and for architecture). This example assumes Linux >= 4.6 (because of info->si_pkey) on x86_64 architecture.



        #!/bin/bash

        . /usr/local/bin/ctypes.sh || exit 2

        handler () {
        local -a info=(int int int int uint32 uint32 int int64 int64 int64 int pointer int int pointer long int short pointer pointer int pointer int unsigned)
        unpack $3 info

        echo ''
        echo "handler($2, info={${info[@]}}, $4);"
        echo -- handling signal $2 --
        echo "info->si_pid=${info[4]}"
        echo "info->si_uid=${info[5]}"
        return
        }
        callback -n handler handler void int pointer pointer

        SIGUSR2=12
        SA_SIGINFO=4

        act=(
        $handler
        long:0 long:0 long:0 long:0 long:0 long:0 long:0 long:0 long:0 long:0 long:0 long:0 long:0 long:0 long:0 long:0
        int:$SA_SIGINFO
        pointer:0
        )
        sizeof_act=$(( 8 + 16 * 8 + 4 + 8 ))

        dlcall -n pact -r pointer malloc $sizeof_act
        [ $pact != pointer:0 ] || exit 1
        pack $pact act

        dlcall -n ret -r int sigaction int:$SIGUSR2 $pact pointer:0
        [ $ret = int:0 ] || exit 1

        echo "sigaction(SIGUSR2, act={${act[@]}}, NULL) = $ret"

        echo ''
        echo run this: kill -$SIGUSR2 $$
        sleep 99


        Execution:



        term1:



        $ ./siginfo.bash 
        sigaction(SIGUSR2, act={pointer:0x7ff26f0d3010 long:0 long:0 long:0 long:0 long:0 long:0 long:0 long:0 long:0 long:0 long:0 long:0 long:0 long:0 long:0 long:0 int:4 pointer:0}, NULL) = int:0

        run this: kill -12 24250


        term2:



        $ echo $$
        21864
        $ id -u
        1000
        $ kill -12 24250
        $


        result in term1:



        handler(int:12, info={int:12 int:0 int:0 int:0 uint32:21864 uint32:1000 int:0 int64:0 int64:0 int64:0 int:0 pointer:0 int:0 int:0 pointer:0 long:0 int:0 short:0 pointer:0 pointer:0 int:0 pointer:0 int:0 unsigned:0}, pointer:0x7fff4583a500);
        -- handling signal int:12 --
        info->si_pid=uint32:21864
        info->si_uid=uint32:1000






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Dec 21 at 3:18









        A.B

        3,9971724




        3,9971724






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Unix & Linux Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.





            Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


            Please pay close attention to the following guidance:


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f489717%2fcatch-which-user-sends-kill-signal%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Morgemoulin

            Scott Moir

            Souastre