logo       


fork_to_background() on Windows: msg#00082

Subject: fork_to_background() on Windows
The "fork-to-background" on Windows is just a joke (as the comment
in config.h.mingw says). Is anybody using it? It could be a useful feature 
if we attach to the console of calling process (the shell in most cases) 
at startup. Then when ^Break is pressed (or '-b' specified), we free
that console and continue running in the background. That way we will
get the shell prompt back (and not as it is know with Wget seemingly 
hanging idle until finished).

A brief description of how I did accomplish this:

* In makefiles, add
  "CFLAGS += -Dmain=wget_main" and
  link wget as a GUI app ("-Wl,--subsystem,windows" or
  "/subsystem:windows")

* In mswindows.c, add a WinMain() function that sets up a detached
  console (or for Win-9x/ME/NT allocates one). Reopen stdin, stdout 
  and stderr using "$CONIN" etc. Call wget_main(). 
  BTW. We could do the Winsock init stuf here too to avoid cluttering
    main.c

* In fork_to_background(), free the attached or allocated console
  seemingly continuing in background.

This actually works fine, but redirection (e.g. wget -h > foo) doesn't 
work.I don't know any way to get at the redirected stdout/stderr handles 
from Wget. But then you're not supposed to do that from a "GUI" app.

I've not tested on anything but Win-XP. I've attached the modfied 
mswindows.c if anybody could try it on other Win OS'es.
(define 'CTRLBREAK_BACKGND' in config.* or makefiles).

Anybody see other ways to run detached or in background. I haven't 
checked how Cygwin's fork() does it, but hear it is pretty slow. 
And can we live without redirection?

Gisle V.

Attachment: mswindows.c
Description: Binary data

Ruby Jobs
Java Jobs
Jobs in California
more...
what
job title, keywords
where
city, state, zip
jobs by job search
Search:
Java, servers, webhosting, windows, cisco ...
more...
<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

Recently Viewed:
encryption.gpg....    ietf.rfc822/199...    freebsd.devel.i...    lang.haskell.li...    mail.squirrelma...    web.zope.plone....    yellowdog.gener...    text.xml.xalan....    recreation.phot...    kde.devel.educa...    hardware.bus.ca...    printing.ghosts...    voip.peering/20...    assembly/2006-0...    org.user-groups...    culture.interne...    network.i2p/200...    boot-loaders.ya...    xfree86.render/...    qnx.openqnx.dev...    jakarta.velocit...    user-groups.pal...   
Home | blog view | USPTO Patent Archive | advertise | OSDir is an inevitable website. super tiny logo

Free Magazines

Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business.
subscribe

Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field.
subscribe

The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business.
subscribe

Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company.
subscribe

Total Telecom Total Telecom is "The Economist of the communications industry".
subscribe