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 1593
On Mon, 2005-10-10 at 22:58 -0700, my********@gmai l.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********@gmai l.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********@gma il.com" <my********@gma il.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.or g> 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********@gmai l.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.n ac.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! 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. It would have a
few buttons as function controls and one main scrollable panel that
acts like a terminal window.
I want to make it so that clicking on a button that performs an
operation will output it to the scrollable wxpython terminal panel,...
|
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 help is greatly appreciated!
Josh
|
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 deployed to our terminal server for
remote users to use. However, normal users (simple domain users) can
not run the application. After double clicking on the icon, an
hourglass appears as if its loading then it goes back to the normal
cursor. ...
|
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 desktop ( On windows
2003 Server ), I need to determine in the code the machine name and
username. If I use GetUsername and GetMachineName, it simply gives me the
name of the currently logged on user ( at the Server ) and the Servers
Machine Name.
|
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 application. it
can be by IP or by machine network name... Doesn't matter.
I am using Visual Basic .Net 2003
Any help would be greatly appreciated.
| |
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 included a code snippet from Chuck Blake 'ls' app in
python. It seems to do the job just fine on my comp, but regrettably,
I'm not sassy enough to wrap my head around the fine grain details on
this one. How cross-platform is this? Is there a more...
|
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
on specified coordinates?
And also: is it possible to override, from python code, something on a
|
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 2 different PC's? I
have 30 users that need to log on to my SQL database.
|
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 out saying
the SQL server cannot be found. This is through the terminal session
and when logged on the server locally.
If I run the apps on my workstation they work fine.
In one of the problem apps, it runs flawless except for a similar...
|
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. Only the office manager
generates reports in Access from this client data.
Now they want to share this Access application with employees at a remote
office. They expect to have a maximum of 30 employees editing the client
list in both the...
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |