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

  • SEARCH
  • Home
  • 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 171093
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T12:55:34+00:00 2026-05-11T12:55:34+00:00

Scenario: There is a complex piece of software that is annoying to launch by

  • 0

Scenario:

There is a complex piece of software that is annoying to launch by hand. What I’ve done is to create a python script to launch the executable and attach gdb for debugging.

The process launching script:

  • ensures an environment variable is set.
  • ensures a local build directory gets added to the environment’s LD_LIBRARY_PATH variable.
  • changes the current working directory to where the executable expects to be (not my design)
  • launches the executable with a config file the only command line option
  • pipes the output from the executable to a second logging process
  • remembers PID of executable, then launches & attaches gdb to running executable.

The script works, with one caveat. ctrl-c doesn’t interrupt the debugee and return control to gdb. So if I ‘continue’ with no active breakpoints I can never stop the process again, it has to be killed/interrupted from another shell. BTW, running ‘kill -s SIGINT <pid>’ where <pid> is the debuggee’s pid does get me back to gdb’s prompt… but it is really annoying to have to do things this way

At first I thought Python was grabbing the SIGINT signal, but this doesn’t seem to be the case as I set up signal handlers forward the signal to the debugee and that doesn’t fix the problem.

I’ve tried various configurations to the python script (calling os.spawn* instead of subprocess, etc.) It seems that any way I go about it, if python launched the child process, SIGINT (ctrl-c) signals DO NOT to get routed to gdb or the child process.

Current line of thinking

  • This might be related to needing a separate process group id for the debugee & gdb…any credence to this?
  • Possible bug with SELinux?

Info:

  • gdb 6.8
  • Python 2.5.2 (problem present with Python 2.6.1 as well)
  • SELinux Environment (bug delivering signals to processes?)

Alternatives I’ve considered:

  • Setting up a .gdbinit file to do as much of what the script does, environment variables and current working directory are a problem with this approach.
  • Launching executable and attaching gdb manually (yuck)

Question: How do you automate the launching/debugging of large scale projects?

Update: I’ve tried Nicholas Riley’s examples below, on my Macintosh at home they all allow cntl-c to work to varrying degrees, on the production boxen (which I now to believe may be running SELinux) they don’t…

  • 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. 2026-05-11T12:55:35+00:00Added an answer on May 11, 2026 at 12:55 pm

    Instead of forwarding the signal to the debuggee from Python, you could try just ignoring it. The following worked for me:

    import signal signal.signal(signal.SIGINT, signal.SIG_IGN)  import subprocess cat = subprocess.Popen(['cat']) subprocess.call(['gdb', '--pid=%d' % cat.pid]) 

    With this I was able to ^C repeatedly inside GDB and interrupt the debuggee without a problem, however I did see some weird behavior.

    Incidentally, I also had no problem when forwarding the signal to the target process.

    import subprocess cat = subprocess.Popen(['cat'])  import signal, os signal.signal(signal.SIGINT,               lambda signum, frame: os.kill(cat.pid, signum))  subprocess.call(['gdb', '--pid=%d' % cat.pid]) 

    So, maybe something else is going on in your case? It might help if you posted some code that breaks.

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

Sidebar

Related Questions

Let us take this example scenario: There exists a really complex function that involves
Scenario : There is this online questionaire that will be filled in by various
Are there any security exploits that could occur in this scenario: eval(repr(unsanitized_user_input), {__builtins__: None},
In my project there is a scenario that user will log in -> browse
The scenario: Big system (~200 tables). 60,000 users. Complex reports that will require me
Imagine a scenario where you have a complex framework of WinRT code that you
Scenario: The method in the controller that saves the data is using some complex
The scenario My team is building a fairly complex MVC3/C# site. There's been some
Scenario: There is a website with 700-900 concurrent unique visitors at any given time.
scenario : there is some pages [ example home ,about us ,contact us etc]

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.