Hi All,
I have a php program which calls a c++ program using exec. However when
user presses stop button in the browser or closes it this program keeps
on running on the server. How can I stop it according to user's
actions.
Thanks in advance.
Sal 15 3828
shyren wrote: Hi All, I have a php program which calls a c++ program using exec. However when user presses stop button in the browser or closes it this program keeps on running on the server. How can I stop it according to user's actions. Thanks in advance. Sal
How can you detect the user pressed the stop button or closed the browser?
--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp. js*******@attgl obal.net
=============== ===
I don't know how to detect that user pressed the stop button or closed
the browser. That is one part of the problem.
Sal
Jerry Stuckle a écrit : shyren wrote: Hi All, I have a php program which calls a c++ program using exec. However
when user presses stop button in the browser or closes it this program
keeps on running on the server. How can I stop it according to user's actions. Thanks in advance. Sal
How can you detect the user pressed the stop button or closed the
browser?
-- =============== === Remove the "x" from my email address Jerry Stuckle JDS Computer Training Corp. js*******@attgl obal.net =============== ===
shyren wrote: I don't know how to detect that user pressed the stop button or closed the browser. That is one part of the problem. Sal
That was more of a rhetorical question. The answer is: you can't.
--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp. js*******@attgl obal.net
=============== ===
shyren (sa********@yah oo.com) wrote:
: Hi All,
: I have a php program which calls a c++ program using exec. However when
: user presses stop button in the browser or closes it this program keeps
: on running on the server. How can I stop it according to user's
: actions.
: Thanks in advance.
: Sal
If the c++ program is sending data to the file handle that is going back
to the browser (normally stdout), then the c++ program _might_ receive an
error when it prints to stdout if the browser is stopped, depending on how
the web server works.
If a web server detected that the file handle to the browser was closed
then I suppose some web servers might signal the cgi. The script and its
children could arrange to be interupted by that.
I would experiment with those two things on the server in question to see
if your program can detect either one.
Both cases depend on the browser closing the socket when you hit the stop
button, which is not something you control.
--
This space not for rent.
shyren wrote: I have a php program which calls a c++ program using exec. However when user presses stop button in the browser or closes it this program keeps on running on the server. How can I stop it according to user's actions.
1. Make sure PHP is not ignoring user's abort commands:
ignore_user_abo rt(false);
2. Write a function that would use exec() to send a kill
signal to the C++ program. On Unix, you could do
something like this:
function kill_my_cpp_pro g() {
// call 'ps -auxww' to get the list of running processes
// find the pid for your C++ program
// call 'kill [pid]' to stop your C++ program
}
Refer to your OS manual for details of ps and kill usage.
3. Register that function to be executed at shutdown:
register_shutdo wn_function('ki ll_my_cpp_prog' );
So when a user aborts, it will trigger execution of
kill_my_cpp_pro g()...
Cheers,
NC
On 20 May 2005 10:07:02 -0700, "NC" <nc@iname.com > wrote: shyren wrote: I have a php program which calls a c++ program using exec. However when user presses stop button in the browser or closes it this program keeps on running on the server. How can I stop it according to user's actions.
1. Make sure PHP is not ignoring user's abort commands:
ignore_user_abo rt(false);
2. Write a function that would use exec() to send a kill signal to the C++ program. On Unix, you could do something like this:
function kill_my_cpp_pro g() { // call 'ps -auxww' to get the list of running processes // find the pid for your C++ program // call 'kill [pid]' to stop your C++ program }
Refer to your OS manual for details of ps and kill usage.
3. Register that function to be executed at shutdown:
register_shutdo wn_function('ki ll_my_cpp_prog' );
So when a user aborts, it will trigger execution of kill_my_cpp_pr og()...
Changing to use proc_open so you can then use proc_terminate might also be
worth thinking about.
There's also posix_kill() for sending signals (but you still have to get the
pid first).
--
Andy Hassall / <an**@andyh.co. uk> / <http://www.andyh.co.uk >
<http://www.andyhsoftwa re.co.uk/space> Space: disk usage analysis tool
Andy Hassall wrote: 1. Make sure PHP is not ignoring user's abort commands:
2. Write a function that would use exec() to send a kill signal to the C++ program.
3. Register that function to be executed at shutdown: Changing to use proc_open so you can then use proc_terminate might also be worth thinking about.
Definitely.
There's also posix_kill() for sending signals (but you still have to get the pid first).
Also, the POSIX extension is often disabled for security purposes...
Cheers,
NC
According to given suggestions I wrote a program for testing. To see
whether I capture the user's abort I write to the file in tmp directory
with writing permissions set. But still I am not able to detect it. i
am new to php and more help would be highly appreciated. Thanks..
_______________ _______________ ____
<?php
ignore_user_abo rt(false);
function kill_my_cpp_pro g()
{
$file=fopen("tm p/num","w");
fputs($file,"nu mber2");
fclose($file);
echo "in";
}
#for($i=0;$i<10 000000;$i++)
# echo $i;
exec("sleep 5");
register_shutdo wn_function('ki ll_my_cpp_prog' );
?>
shyren,
You should most likely move the register_shutdo wn_function to right
after the function kill_my_cpp_pro g as so:
<?php
ignore_user_abo ut(false);
function kill_my_cpp_pro g() {
...
}
register_shutdo wn_function('ki ll_my_cpp_prog' );
....
Because the way you have it now, it will not register the shutdown
function until the script completes.
Mike This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Harald Armin Massa |
last post by:
I need to do some synchronisations like in a cron.job
import time
from threading import Thread
class updater(Thread):
def run(self):
while True:
do_updates()
time.sleep(600)
|
by: Eric Osman |
last post by:
My javascript program has reason to want to stop.
For example, function A has 5 lines, the second of which calls function
B, which has 5 lines, the first of which calls function C.
But function C discovers that something is very wrong so it does an
"alert" saying something like
Sorry, couldn't make the necessary connection
|
by: Mike Bennett |
last post by:
Does the .NET framework (using VB.NET) support the ability to programmatically STOP a device prior to its removal from the system?
I have need to move data from a computer on one network to a computer on a different network. For various reasons, I am not allowed to join these networks. Additionally, neither computer is allowed to disconnect from its network to connect to the other network
I have decided to use a USB jump drive to move the...
|
by: prakashsha |
last post by:
HI,
I've an asp.net page which has a button. On click of the button the program
queries the database and gets the result and displays the same.Now assume
that my program takes 2 minutes to get the results.In the mean time if the
user press Esc button to stop the process. The page will stop processing but
my database connection will be trying to retrieve the records. How to solve
this ??? Thanks in Adavance.
|
by: electrician |
last post by:
While running a program that exceeds the array limits it issues an
alert. I want to then stop the program after filling in the output
boxes with blanks. How do you stop the program?
I have worked on this for days and tried searching the net, but have
found nothing.
| |
by: darthghandi |
last post by:
I've created a class to listen to all interfaces and do a
BeginAccept(). Once it gets a connection, it passes the connected
socket off and stores it in a List. Next, it continues to listen for
more incoming connections and does the BeginAccpet() again. It does
an infinite loop this way. My question is: What is the best way to
stop this? I thought about putting a boolean in there, but then what
if it's still waiting for an incoming...
|
by: =?Utf-8?B?S2Vubnk=?= |
last post by:
I have one bat file that contains a command to startup Java Program. Then, I
would like to create a cluster job to call the bat file. In case of one
computer is down, another computer can also call the bat file and startup my
Java Program.
For this purpose, I have tried to place the bat file into share drive of two
computers which are cluster machine. Also, I used Generic Application to
create a job to call my bat file and this job is...
|
by: goron |
last post by:
Hello,
I am writing a computationally heavy program which I know will need to run for many hours. Therefore, I need to make it possible to stop the program at any time while it's running and save my progress in an external file so that later the program can be started again and continue from where it left off. What I don't know how to do is how to actually get the program to stop, but make sure it executes some functions to save its progress...
|
by: =?Utf-8?B?am1hZ2FyYW0=?= |
last post by:
My program needs to do X when someone 'starts using' their Windows user
account, and it should do Y when they 'stop using' their Windows user
account. By 'starts using' I mean they log on, unlock the desktop, resume
from hibernate/sleep, or resume a session that was paused via Switch User. By
'stop using' I mean they lock the desktop, initiate a hibernate/sleep
, or choose Switch User while logged on. For context, the program is a
parental...
|
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: 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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |