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 953005
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T23:58:54+00:00 2026-05-15T23:58:54+00:00

From my understanding, os.popen() opens a pipe within Python and initiates a new sub

  • 0

From my understanding, os.popen() opens a pipe within Python and initiates a new sub process. I have a problem when I run a for loop in conjunction with os.popen(). I can’t seem to CTRL+C out of the loop. Here is my code:

for FILE in os.popen("ls $MY_DIR/"):
    os.system("./processFile " + FILE)

Whenever I try to CTRL+C, Python will stop the ./processFile program but NOT the python program itself!

I have Google’d around and couldn’t seem to find the correct answer. Some people recommend using SIGNALS (I tried… it didn’t work). Another tried to use PIDs and killing child PIDs but I couldn’t seem to get it.

Can someone lead me to a better example so I can stop the programming when I use CTRL+C (SIGINT) ?

  • 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-15T23:58:55+00:00Added an answer on May 15, 2026 at 11:58 pm

    I see some answer correctly recommended subprocess.check_call and the OP in a comment said

    I’m getting this error:
    AttributeError: ‘module’ object has no
    attribute ‘check_call’

    Per the docs I just linked to, check_call is marked as:

    New in version 2.5.

    so it looks like the OP is using some ancient version of Python — 2.4 or earlier — without mentioning the fact (the current production-ready version is 2.7, and 2.4 is many years old).

    The best one can recommend, therefore, is to upgrade! If 2.7 is “too new” for your tastes (as it might be considered in a conservative “shop”), 2.6’s latest microrelease should at least be fine — and it won’t just give you subprocess.check_call, but also many additional feautures, bug fixes, and optimizations!-)

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

Sidebar

Ask A Question

Stats

  • Questions 493k
  • Answers 493k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer The code posted is not complete. The error is not… May 16, 2026 at 10:54 am
  • Editorial Team
    Editorial Team added an answer the center tag deprecated use styles instead e.g. margin: 0… May 16, 2026 at 10:54 am
  • Editorial Team
    Editorial Team added an answer Activity class fields: private static final int KEY_TIMEOUT = 60000;… May 16, 2026 at 10:54 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I'm having a problem with Python's subprocess.Popen method. Here's a test script which demonstrates
I have a pretty basic understanding of the GUI thread and the message loop,
i need some help understanding how i can create a new custom event. i
Having problem understanding Delegate error. Error says expression expected, How do I fix? Thanks
I tried to write generic function that remove the duplicate elements from array. public
I think I have got some grasp over basic WPF fundaes. Now I want
Right now, I use a combination of Python and R for all of my
The problem is mostly summed up in the title. I am using the custom
I am trying to create a WCF Streaming Service. I have two requirements that
Need help understanding what I am doing with the syntax here, please help! I

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.