How to fix 'Bus Error' in python code to receive a signal?2019 Community Moderator ElectionHow do I copy a file in Python?How can I safely create a nested directory in Python?How can I remove a trailing newline in Python?How do I parse a string to a float or int in Python?How to get the current time in PythonHow can I make a time delay in Python?How to know if an object has an attribute in PythonHow to get the number of elements in a list in Python?How to concatenate two lists in Python?How to lowercase a string in Python?

How could a female member of a species produce eggs unto death?

Plywood subfloor won't screw down in a trailer home

Force user to remove USB token

Is it true that real estate prices mainly go up?

Format picture and text with TikZ and minipage

Is all copper pipe pretty much the same?

Can the druid cantrip Thorn Whip really defeat a water weird this easily?

Sword in the Stone story where the sword was held in place by electromagnets

Co-worker team leader wants to inject the crap software product of his friends into our development. What should I say to our common boss?

US to Europe trip with Canada layover- is 52 minutes enough?

Is "history" a male-biased word ("his+story")?

Is King K. Rool's down throw to up-special a true combo?

Making a sword in the stone, in a medieval world without magic

Fourth person (in Slavey language)

Excess Zinc in garden soil

Who is our nearest neighbor

Counter-example to the existence of left Bousfield localization of combinatorial model category

Does splitting a potentially monolithic application into several smaller ones help prevent bugs?

How to deal with a cynical class?

Why do Australian milk farmers need to protest supermarkets' milk price?

Single word request: Harming the benefactor

Unreachable code, but reachable with exception

Is a lawful good "antagonist" effective?

Should we release the security issues we found in our product as CVE or we can just update those on weekly release notes?



How to fix 'Bus Error' in python code to receive a signal?



2019 Community Moderator ElectionHow do I copy a file in Python?How can I safely create a nested directory in Python?How can I remove a trailing newline in Python?How do I parse a string to a float or int in Python?How to get the current time in PythonHow can I make a time delay in Python?How to know if an object has an attribute in PythonHow to get the number of elements in a list in Python?How to concatenate two lists in Python?How to lowercase a string in Python?










0















I created a python code following this description:



import os
import time
import signal

def receiveSignal(signalNumber, frame):
print('Received:', signalNumber)
return

signal.signal(signal.SIGUSR1, receiveSignal)

# output current process id
print('My PID is:', os.getpid())

# wait in an endless loop for signals
while True:
print('Waiting...')
time.sleep(3)


which runs fine. But when I try to send a SIGUSR1 signal from another terminal, e.g. :



kill -10 55947


the python code fails as follows:



My PID is: 55947
Waiting...
Waiting...
Bus error: 10


The code is running on MacOS 10.13.6, and I tried using python 2.7.12 and python 3.6.2. In both cases I get that Bus Error.



Is there a way to fix that? Maybe this is a mac issue? I expect the running code to execute the method receiveSignal, but otherwise stay in the shile loop.










share|improve this question






















  • Try kill -SIGUSR1 <pid> instead of the kill -10 <pid> :-P. If you use the string presentation of the signal, then you do not make a mistake with an incorrect signal number.

    – s3n0
    Mar 6 at 18:15















0















I created a python code following this description:



import os
import time
import signal

def receiveSignal(signalNumber, frame):
print('Received:', signalNumber)
return

signal.signal(signal.SIGUSR1, receiveSignal)

# output current process id
print('My PID is:', os.getpid())

# wait in an endless loop for signals
while True:
print('Waiting...')
time.sleep(3)


which runs fine. But when I try to send a SIGUSR1 signal from another terminal, e.g. :



kill -10 55947


the python code fails as follows:



My PID is: 55947
Waiting...
Waiting...
Bus error: 10


The code is running on MacOS 10.13.6, and I tried using python 2.7.12 and python 3.6.2. In both cases I get that Bus Error.



Is there a way to fix that? Maybe this is a mac issue? I expect the running code to execute the method receiveSignal, but otherwise stay in the shile loop.










share|improve this question






















  • Try kill -SIGUSR1 <pid> instead of the kill -10 <pid> :-P. If you use the string presentation of the signal, then you do not make a mistake with an incorrect signal number.

    – s3n0
    Mar 6 at 18:15













0












0








0








I created a python code following this description:



import os
import time
import signal

def receiveSignal(signalNumber, frame):
print('Received:', signalNumber)
return

signal.signal(signal.SIGUSR1, receiveSignal)

# output current process id
print('My PID is:', os.getpid())

# wait in an endless loop for signals
while True:
print('Waiting...')
time.sleep(3)


which runs fine. But when I try to send a SIGUSR1 signal from another terminal, e.g. :



kill -10 55947


the python code fails as follows:



My PID is: 55947
Waiting...
Waiting...
Bus error: 10


The code is running on MacOS 10.13.6, and I tried using python 2.7.12 and python 3.6.2. In both cases I get that Bus Error.



Is there a way to fix that? Maybe this is a mac issue? I expect the running code to execute the method receiveSignal, but otherwise stay in the shile loop.










share|improve this question














I created a python code following this description:



import os
import time
import signal

def receiveSignal(signalNumber, frame):
print('Received:', signalNumber)
return

signal.signal(signal.SIGUSR1, receiveSignal)

# output current process id
print('My PID is:', os.getpid())

# wait in an endless loop for signals
while True:
print('Waiting...')
time.sleep(3)


which runs fine. But when I try to send a SIGUSR1 signal from another terminal, e.g. :



kill -10 55947


the python code fails as follows:



My PID is: 55947
Waiting...
Waiting...
Bus error: 10


The code is running on MacOS 10.13.6, and I tried using python 2.7.12 and python 3.6.2. In both cases I get that Bus Error.



Is there a way to fix that? Maybe this is a mac issue? I expect the running code to execute the method receiveSignal, but otherwise stay in the shile loop.







python macos signals






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Mar 6 at 17:41









AlexAlex

14.4k37129255




14.4k37129255












  • Try kill -SIGUSR1 <pid> instead of the kill -10 <pid> :-P. If you use the string presentation of the signal, then you do not make a mistake with an incorrect signal number.

    – s3n0
    Mar 6 at 18:15

















  • Try kill -SIGUSR1 <pid> instead of the kill -10 <pid> :-P. If you use the string presentation of the signal, then you do not make a mistake with an incorrect signal number.

    – s3n0
    Mar 6 at 18:15
















Try kill -SIGUSR1 <pid> instead of the kill -10 <pid> :-P. If you use the string presentation of the signal, then you do not make a mistake with an incorrect signal number.

– s3n0
Mar 6 at 18:15





Try kill -SIGUSR1 <pid> instead of the kill -10 <pid> :-P. If you use the string presentation of the signal, then you do not make a mistake with an incorrect signal number.

– s3n0
Mar 6 at 18:15












1 Answer
1






active

oldest

votes


















1














I think, the problem is, in MacOS, the SIGNAL 10 means SIGBUS.



See the signal list https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man3/signal.3.html



See the signal details,



 1 SIGHUP terminate process terminal line hangup
2 SIGINT terminate process interrupt program
3 SIGQUIT create core image quit program
4 SIGILL create core image illegal instruction
5 SIGTRAP create core image trace trap
6 SIGABRT create core image abort program (formerly SIGIOT)
7 SIGEMT create core image emulate instruction executed
8 SIGFPE create core image floating-point exception
9 SIGKILL terminate process kill program
10 SIGBUS create core image bus error
...
...
30 SIGUSR1 terminate process User defined signal 1
31 SIGUSR2 terminate process User defined signal 2


Hence, the error.



Try sending SIGNAL 30, and see :)






share|improve this answer
























    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    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: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    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%2fstackoverflow.com%2fquestions%2f55029188%2fhow-to-fix-bus-error-in-python-code-to-receive-a-signal%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1














    I think, the problem is, in MacOS, the SIGNAL 10 means SIGBUS.



    See the signal list https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man3/signal.3.html



    See the signal details,



     1 SIGHUP terminate process terminal line hangup
    2 SIGINT terminate process interrupt program
    3 SIGQUIT create core image quit program
    4 SIGILL create core image illegal instruction
    5 SIGTRAP create core image trace trap
    6 SIGABRT create core image abort program (formerly SIGIOT)
    7 SIGEMT create core image emulate instruction executed
    8 SIGFPE create core image floating-point exception
    9 SIGKILL terminate process kill program
    10 SIGBUS create core image bus error
    ...
    ...
    30 SIGUSR1 terminate process User defined signal 1
    31 SIGUSR2 terminate process User defined signal 2


    Hence, the error.



    Try sending SIGNAL 30, and see :)






    share|improve this answer





























      1














      I think, the problem is, in MacOS, the SIGNAL 10 means SIGBUS.



      See the signal list https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man3/signal.3.html



      See the signal details,



       1 SIGHUP terminate process terminal line hangup
      2 SIGINT terminate process interrupt program
      3 SIGQUIT create core image quit program
      4 SIGILL create core image illegal instruction
      5 SIGTRAP create core image trace trap
      6 SIGABRT create core image abort program (formerly SIGIOT)
      7 SIGEMT create core image emulate instruction executed
      8 SIGFPE create core image floating-point exception
      9 SIGKILL terminate process kill program
      10 SIGBUS create core image bus error
      ...
      ...
      30 SIGUSR1 terminate process User defined signal 1
      31 SIGUSR2 terminate process User defined signal 2


      Hence, the error.



      Try sending SIGNAL 30, and see :)






      share|improve this answer



























        1












        1








        1







        I think, the problem is, in MacOS, the SIGNAL 10 means SIGBUS.



        See the signal list https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man3/signal.3.html



        See the signal details,



         1 SIGHUP terminate process terminal line hangup
        2 SIGINT terminate process interrupt program
        3 SIGQUIT create core image quit program
        4 SIGILL create core image illegal instruction
        5 SIGTRAP create core image trace trap
        6 SIGABRT create core image abort program (formerly SIGIOT)
        7 SIGEMT create core image emulate instruction executed
        8 SIGFPE create core image floating-point exception
        9 SIGKILL terminate process kill program
        10 SIGBUS create core image bus error
        ...
        ...
        30 SIGUSR1 terminate process User defined signal 1
        31 SIGUSR2 terminate process User defined signal 2


        Hence, the error.



        Try sending SIGNAL 30, and see :)






        share|improve this answer















        I think, the problem is, in MacOS, the SIGNAL 10 means SIGBUS.



        See the signal list https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man3/signal.3.html



        See the signal details,



         1 SIGHUP terminate process terminal line hangup
        2 SIGINT terminate process interrupt program
        3 SIGQUIT create core image quit program
        4 SIGILL create core image illegal instruction
        5 SIGTRAP create core image trace trap
        6 SIGABRT create core image abort program (formerly SIGIOT)
        7 SIGEMT create core image emulate instruction executed
        8 SIGFPE create core image floating-point exception
        9 SIGKILL terminate process kill program
        10 SIGBUS create core image bus error
        ...
        ...
        30 SIGUSR1 terminate process User defined signal 1
        31 SIGUSR2 terminate process User defined signal 2


        Hence, the error.



        Try sending SIGNAL 30, and see :)







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Mar 6 at 18:05

























        answered Mar 6 at 18:00









        han solohan solo

        1,11016




        1,11016





























            draft saved

            draft discarded
















































            Thanks for contributing an answer to Stack Overflow!


            • 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%2fstackoverflow.com%2fquestions%2f55029188%2fhow-to-fix-bus-error-in-python-code-to-receive-a-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

            AWS Lex not identifying response if by a variable The 2019 Stack Overflow Developer Survey Results Are In Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern) The Ask Question Wizard is Live! Data science time! April 2019 and salary with experienceEnforcing custom enumeration in AWS LEX for slot valuesHow to give response based on user response in Amazon Lex?Intercepting AWS Lambda Response to a AWS Lex QueryLex chat bot error: Reached second execution of fulfillment lambda on the same utteranceamazon lex showing invalid responseLambda response send back to Lex slot?Response card in Amazon lexAmazon Lex - Lambda response return HTML to botHow can I solve 424 (Failed Dependency) (python) obtained from Amazon lex?

            Алба-Юлія

            Захаров Федір Захарович