Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6162277
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T21:37:34+00:00 2026-05-23T21:37:34+00:00

The following (a small C program and a python script that calls it) behave

  • 0

The following (a small C program and a python script that calls it)
behave differently across various Unixes.

In some of them (e.g. Debian stable), the C app gets the signal,
the message is printed fine from the signal handler and the script
finishes. In others (e.g. a two year-old Ubuntu and an OpenBSD)
the signal is lost, and therefore the message is not printed at all,
and the script waits forever…

The signal is ALWAYS delivered, if in the python script, I change this…

mysub=subprocess.Popen("./cryInAbort", shell=True)

into this…

mysub=subprocess.Popen("./cryInAbort", shell=False)

So it appears that in some Unixes the intermediate shell “eats” the SIGINT,
while in others it forwards it to the child process (the C program).

I took care to only call re-entrant functions in the signal handler
so this doesn’t seem to be related to my C code – it looks as if
signal handling behavior within “/bin/sh” (the default shell used
by Python to spawn things) is not “stable” across Unixes…

Am I doing something wrong?

EDIT: In case you are wondering why I used “shell=True”: it’s because in my real code, I am not just passing “./executable” – I am using shell code for loops and wildcards.

This is the C code that prints and dies when it gets SIGINT:

#include <signal.h>
#include <unistd.h>

void my_handler()
{
    static const char msg[] = "Goodbye - test was OK.\n";
    write(1,msg,sizeof(msg));
    fsync(1);
    _exit (0);
}

int main()
{
    (void) signal (SIGINT, my_handler);
    while (1);
}

And this is the Python script that tests it by sending SIGINT:

#!/usr/bin/env python
import subprocess,signal,time
mysub=subprocess.Popen("./cryInAbort", shell=True)
time.sleep(2)
mysub.send_signal(signal.SIGINT)
mysub.wait()
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T21:37:35+00:00Added an answer on May 23, 2026 at 9:37 pm

    Just because Python uses /bin/sh doesn’t mean it’s the same shell on all systems.

    /bin/sh is almost always an alias in the form of a symbolic link: the real shell could be busybox, bash, ash, csh, ksh, dash, zsh, tcsh, or something crazy(er).

    Confirm that you’re actually using the same shell on all the systems, then if the problem is a specific shell you know where to look for more information on it’s behavior.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am writing a small test program that gives the following xml file as
I am having some issues with a small program I have made that edits
I encounter the following small annoying dilemma over and over again in Python: Option
I am saving some small images to Xml as a Byte[] via the following
I've written small gui-frontend in Python that lets users play internet radio channels. The
am trying to get my head around the following: Have a small program am
Source of the problem -Accelerated C++, problem 8-5 I've written a small program that
I want to write a small program that should print something like testing CPU...
I am writing some small program in C--some log in, log out, create account,
I am working on a small c++ program and learning exceptions. Is the following

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.