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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T03:06:04+00:00 2026-05-25T03:06:04+00:00

When using os.system to open a file, eg: os.system(r’C:/foo.txt’) , the current Python process,

  • 0

When using os.system to open a file, eg: os.system(r'C:/foo.txt'), the current Python process, of course, waits until the system-call returns. (ie.: the text-editor closes).
Do I have to use a Thread to make this asynchronous ?

Imagine the following situation:

I’m writing a File-manager for Windows using Python. The user clicks on a file. Now using os.system(the_path_to_the_file_clicked) will open the file with the default programm, as set in the registry.
Using a Thread to make the system-call asynchronous would work quite well, but what when the user closes the File-manager ? The Python process would stay alive until the Thread exits, but this isn’t this unnecessery ? And on the other hand, terminating the Python-process would terminate the Thread as well, the program closes.

Is there a way to use a system-call to open a new process, independent from the Python-process ?

  • 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-25T03:06:05+00:00Added an answer on May 25, 2026 at 3:06 am

    If you want to open a file on windows with the default program, there’s a special function that opens it asynchronously and independently of your own program: os.startfile. This should do what you want.

    More generally, for running programs asynchronously, os.system can’t do it. However, the subprocess module can. The subprocess module does nearly everything os.system does, plus much more. However, like with os.system, when you use subprocess.Popen, the program is not opened independently of your process — when your process dies, so does the subprocess.

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

Sidebar

Related Questions

I'm using System.Xml to read a xml file in C#. First I open the
Is it possible to read from a file which is opened using open system
I'm trying to open and read from a serial port using the System.IO.Ports.SerialPort class.
I've done this function in C using system calls (open, read and write) to
As part of an assignment, I'm supposed to write to a file using system
Hey guys using POSIX API system calls read , write , open , etc.
Question I want to programmatically open a RTF file in Microsoft Word using C#.
My program basically looks like this: using(XmlReader reader = XmlReader.Create(File.Open(path, FileMode.Open, FileAccess.Reader, FileShare.Read)) {
I'm using System.Xml to get attributes from my xml file . It seems that
I am trying to add Images using open file dialog and folder browse dialog

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.