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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T15:35:05+00:00 2026-05-24T15:35:05+00:00

When I open Firefox, then run the command: firefox http://somewebsite the url opens in

  • 0

When I open Firefox, then run the command:

firefox http://somewebsite

the url opens in a new tab of Firefox (same thing happens with Chromium as well). Is there some way to replicate this behavior in Python? For example, calling:

processStuff.py file/url

then calling:

processStuff.py anotherfile

should not start two different processes, but send a message to the currently running program. For example, you could have info in one tabbed dialog box instead of 10 single windows.

Adding bounty for anyone who can describe how Firefox/Chromium do this in a cross-platform way.

  • 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-24T15:35:05+00:00Added an answer on May 24, 2026 at 3:35 pm

    The way Firefox does it is: the first instance creates a socket file (or a named pipe on Windows). This serves both as a way for the next instances of Firefox to detect and communicate with the first instance, and forward it the URL before dying. A socket file or named pipe being only accessible from processes running on the local system (as files are), no network client can have access to it. As they are files, firewalls will not block them either (it’s like writing on a file).

    Here is a naive implementation to illustrate my point. On first launch, the socket file lock.sock is created. Further launches of the script will detect the lock and send the URL to it:

    import socket
    import os
    
    SOCKET_FILENAME = 'lock.sock'
    
    def server():
        print 'I\'m the server, creating the socket'
        s = socket.socket(socket.AF_UNIX, socket.SOCK_DGRAM)
        s.bind(SOCKET_FILENAME)
    
        try:
            while True:
                print 'Got a URL: %s' % s.recv(65536)
        except KeyboardInterrupt, exc:
            print 'Quitting, removing the socket file'
            s.close
            os.remove(SOCKET_FILENAME)
    
    def client():
        print 'I\'m the client, opening the socket'
        s = socket.socket(socket.AF_UNIX, socket.SOCK_DGRAM)
        s.connect(SOCKET_FILENAME)
        s.send('http://stackoverflow.com')
        s.close()
    
    def main():
        if os.path.exists(SOCKET_FILENAME):
            try:
                client()
            except (socket.error):
                print "Bad socket file, program closed unexpectedly?"
                os.remove(SOCKET_FILENAME)
                server()
        else:
            server()
    
    main()
    

    You should implement a proper protocol (send proper datagrams instead of hardcoding the length for instance), maybe using SocketServer, but this is beyond this question. The Python Socket Programming Howto might also help you. I have no Windows machine available, so I cannot confirm that it works on that platform.

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

Sidebar

Related Questions

The following javascript opens a pop-up in Firefox, Safari, IE, and Google Chrome: window.open(http://google.com,
If Safari/Firefox have already downloaded files then they keep a download manager window open.
I am creating a Firefox Extension...what would be the javascript to open a URL
I have code to copy a file to a new location, then open the
My browser (firefox) prevents any popup from loading, and loads links that open new
I'm having to open the firefox error console, which is kind of annoying.
My website is working fine on IE, but when I open it on Firefox,
Firefox doesn't know how to open this address because the protocol (c) isn't associated
I am building an open search add-on for Firefox/IE and the image needs to
Often when browsing in Firefox, I'll right click on a link, and open it

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.