Hello,
A user of my application points me to a behavior in gVim,
the text editor, that I would like to implement in my
application.
When gVim is launched from a shell terminal, it completely
frees the terminal. You can continue to use the terminal for
whatever purpose you wish, including closing and exiting it,
without any effect on the running gVim instance.
How do I implement this in my application written in python?
I would like to believe it does not involve me forking my
application in a new process. Maybe there is signal I can
send to the operating system to achieve this, right?
Your help is appreciated.
Thanks 14 1577
On Mon, 2005-10-10 at 22:58 -0700, my********@gmail.com wrote: Hello,
A user of my application points me to a behavior in gVim, the text editor, that I would like to implement in my application.
When gVim is launched from a shell terminal, it completely frees the terminal. You can continue to use the terminal for whatever purpose you wish, including closing and exiting it, without any effect on the running gVim instance.
How do I implement this in my application written in python? I would like to believe it does not involve me forking my application in a new process. Maybe there is signal I can send to the operating system to achieve this, right?
gvim forks. Why do you want to avoid it?
import os, sys
pid = os.fork()
if pid !=0:
# exit parent
sys.exit(0)
# child continues my********@gmail.com enlightened us with: When gVim is launched from a shell terminal, it completely frees the terminal. [...] How do I implement this in my application written in python?
Using fork() and by catching the HUP signal.
Sybren
--
The problem with the world is stupidity. Not saying there should be a
capital punishment for stupidity, but why don't we just take the
safety labels off of everything and let the problem solve itself?
Frank Zappa
"my********@gmail.com" <my********@gmail.com> writes: Hello,
A user of my application points me to a behavior in gVim, the text editor, that I would like to implement in my application.
When gVim is launched from a shell terminal, it completely frees the terminal. You can continue to use the terminal for whatever purpose you wish, including closing and exiting it, without any effect on the running gVim instance.
How do I implement this in my application written in python? I would like to believe it does not involve me forking my application in a new process. Maybe there is signal I can send to the operating system to achieve this, right?
Several things need to happen.
First, you need to take yourself out of the session you are in. To do
that, you use the setsid system call. This is available in python as
os.setsid.
Last, you need to detach your process from the terminal. You do that
by closing all the file descriptors you have that reference it. stdin,
stdout and stderr should do the trick. The standard trick is to set
set them to /dev/null. This has to happen last, so that if there are
problems in the second step, writing to stderr about it does some
good.
Second, you need to tell the shell that launched you that it can
continue. The standard way to do this is to fork your process, and
have the parent exit. That causes the parent shell to think your
process is dead, and so forget about it completely. There are other
ways to do this, but they aren't as reliable.
The easy way to do all these things - from C, anyway - is with
daemon(3). That isn't wrapped as part of the Python library. The
easiest way to solve your problem may be write a wrapper for that
call. If daemon exists on enough systems, submitting your wrapper as a
patch to the os modulee would be appropriate.
<mike
--
Mike Meyer <mw*@mired.org> http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
On 10 Oct 2005 22:58:08 -0700 my********@gmail.com wrote: How do I implement this in my application written in python?
Google for "python daemonize".
--
jk
Hello,
Thank you. That's all I needed. For some reason, I had always assumed
forking was an expensive process. I guess I was ill-informed.
Hello,
Thanks to all the responders and helpers on the group. I'm learning
everyday.
Thanks
Mike Meyer wrote: The easy way to do all these things - from C, anyway - is with daemon(3). That isn't wrapped as part of the Python library. The easiest way to solve your problem may be write a wrapper for that call. If daemon exists on enough systems, submitting your wrapper as a patch to the os modulee would be appropriate.
I think the deamon() library call only exists on the BSDs. Anyway, there
it is implemented with a fork() call and some additional code to close
std descriptors, so there's no practical difference between calling
deamon() and fork() by yourself...
On Tue, 11 Oct 2005 03:30:23 -0700, Mystilleef wrote: Hello,
Thank you. That's all I needed. For some reason, I had always assumed forking was an expensive process. I guess I was ill-informed.
In a loop, yes, it's expensive.
Done once, it's usually not unacceptable.
On Tue, 11 Oct 2005 22:01:23 GMT, Dan Stromberg <st******@dcs.nac.uci.edu> wrote: On Tue, 11 Oct 2005 03:30:23 -0700, Mystilleef wrote:
Hello,
Thank you. That's all I needed. For some reason, I had always assumed forking was an expensive process. I guess I was ill-informed. In a loop, yes, it's expensive.
It depends on what you mean by expensive -- web servers can fork for each
HTTP request they get, in real-world scenarios, and get away with it.
Done once, it's usually not unacceptable.
In fact, I can't think of a scenario where it /would/ be unacceptable ;-)
But back to the original problem: I can't really see why anybody would need
the "let my terminal go" feature. Is there a reason why 'gvim foo.txt&'
isn't good enough?
/Jorgen
--
// Jorgen Grahn <jgrahn@ Ph'nglui mglw'nafh Cthulhu
\X/ algonet.se> R'lyeh wgah'nagl fhtagn!
Jorgen Grahn <jg*********@algonet.se> writes: It depends on what you mean by expensive -- web servers can fork for each HTTP request they get, in real-world scenarios, and get away with it.
This is OS dependent. Forking on Windows is much more expensive than
forking on Linux.
On 2005-10-13, Paul Rubin <> wrote: Jorgen Grahn <jg*********@algonet.se> writes: It depends on what you mean by expensive -- web servers can fork for each HTTP request they get, in real-world scenarios, and get away with it.
This is OS dependent. Forking on Windows is much more expensive than forking on Linux.
Under VMS, fork/exec was so expensive that the Bourne shell
implimentation in DECShell executed "simple" commands in the
shell's process rather than do a fork/exec. Shell scripts that
used pipes or similar constructs requiring fork/exec ran _very_
slowly under DECShell.
Since the NT kernel is descended from VMS, I'm not surprised
that a fork is expensive.
--
Grant Edwards grante Yow! Why are these
at athletic shoe salesmen
visi.com following me??
Grant Edwards <gr****@visi.com> writes: Since the NT kernel is descended from VMS, I'm not surprised that a fork is expensive.
Apache 2.x supports concurrency via threading as an alternative to
forking, basically in order to get acceptable performance on Windows.
Jorgen Grahn wrote: Done once, it's usually not unacceptable.
In fact, I can't think of a scenario where it /would/ be unacceptable ;-)
if you're stuck on a system that doesn't use copy-on-write ?
</F>
On 13 Oct 2005 09:54:44 -0700, Paul Rubin <http> wrote: Jorgen Grahn <jg*********@algonet.se> writes: It depends on what you mean by expensive -- web servers can fork for each HTTP request they get, in real-world scenarios, and get away with it.
This is OS dependent. Forking on Windows is much more expensive than forking on Linux.
Forking, to me, means doing what the Unix fork(2) system call does. Since
AFAIK there is no corresponding Win32 call, I assumed the original poster
was on Unix.
But now I see that he didn't use the word "fork"; someone else in the thread
did ...
You are correct, of course; the cost of spawning processes varies a lot
between OSes, and it's distinctly higher on Windows compared to Unixes in
general and Linux in particular.
(BTW, Eric Raymond argues that low-cost spawning is an important
characteristic of an OS: see http://www.faqs.org/docs/artu/ch03s01.html#id2892171 )
/Jorgen
--
// Jorgen Grahn <jgrahn@ Ph'nglui mglw'nafh Cthulhu
\X/ algonet.se> R'lyeh wgah'nagl fhtagn! This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: flamesrock |
last post by:
First, I'm very new to gui programming, so please go lightly on me :)
Ok, so far I've settled on wxPython, and what I'd like to do as a first
leap is *convert* a text program into a gui program....
|
by: Josh Schmidt |
last post by:
How can one set the terminal services profile and home
directory path in AD using VB.NET? I can set the usual
profile paths, but terminal services properties are not
supported with ADSI.
Any...
|
by: TPoise! |
last post by:
Using: .NET 1.1, Visual Studio 2003, C#, Microsoft Windows 2000
Server (SP4 and all latest windows updates), Terminal Server running
in application mode.
I have a C# application that I've...
|
by: OHM |
last post by:
Hi peoples,
I dont know where to place this question, so as I know you guys are all
resourceful experts, I thought I would try here.
I am writing some code which will be run usingh remote...
|
by: Atley |
last post by:
I have a Terminal Services server running Windows 2000 Server.
I need to be able to identify, in my application on that server, which
client computer is addressing that server and running that...
| |
by: Joel Hedlund |
last post by:
Hi all!
I use python for writing terminal applications and I have been bothered
by how hard it seems to be to determine the terminal size. What is the
best way of doing this?
At the end I've...
|
by: fivestars |
last post by:
Hi there.
I'm computer science student at the end of my degree. I'm new about
python.
I've a question for all of you.
Do you know how to write, from python code, on a unix(linux) terminal...
|
by: shawn |
last post by:
In the past I have had SQL and Terminal server on the same PC.
With SQL and Windows 2003 Terminal server, you can not have them on the
same PC.
How can I make this work with SQL and Terminal and...
|
by: mike |
last post by:
We have numerous Access 97 apps that we run on our Terminal Server,
but two apps in particular is giving us a problem. The problem we are
running into is when you select a drop down menu, it errors...
|
by: =?Utf-8?B?RHdlZWJlcmVsbGE=?= |
last post by:
I created an Access 2007 application for my customer. The application is
shared by three employees on a server. It maintains a contact list including
financial data and social security numbers. ...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...
| |