Hello NG!
I have following situation:
c-prg | webprg
"c-prg" is a small c-programm which reads data from an fastCgi-Server and
writes them to stdout.
The stdout is piped into webprg.
"webprg" is an 4th-GL Application that reads Data from StdIn and writes Data
to an fifo-pipe.
"c-prg" reads data from the fifo-pipe and writes them back to the
FastCGI-Server.
Sometimes "webprg" stopps for different reasons.
But "c-prg" is still alive and the Fast-CGI-Server has no reason to restart
the process-chain.
So, is there a way to determine if a subprocess is still alive.
But keep in mind, that the subprocess (webprg) is not forked inside the
parentprocess. It is just a pipe-chain.
The following c-source is from "c-prg"
Many thanks for any ideas in advance!
Sig
/*
*
* Produce a page containing all the inputs (fcgiapp version)
*
*
* Copyright (c) 1996 Open Market, Inc.
*
* See the file "LICENSE.TERMS" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
*/
#ifndef lint
static const char rcsid[] = "$Id: echo-x.c,v 1.1 2001/06/19 15:06:17 robs
Exp $";
#endif /* not lint */
#include <stdio.h>
#include "fcgi_config.h"
#include <stdlib.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#ifdef _WIN32
#include <process.h>
#else
extern char **environ;
#endif
#include "fcgiapp.h"
#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
static void PrintEnv(FCGX_Stream *out, char *label, char **envp)
{
for( ; *envp != NULL; envp++) {
printf("%s\n", *envp);
}
}
int main ()
{
FCGX_Stream *in, *out, *err;
FCGX_ParamArray envp;
int count = 0;
int in_count;
int fd_fifo, pid;
char buffer[4096];
char fifo[30];
mode_t mode = 0666;
pid = getpid();
sprintf(fifo, "/tmp/fifo_%d", pid);
if((mkfifo(fifo, mode)) == -1) {
FCGX_FPrintF(out,"Cannot create %s",fifo);
return (-1);
}
printf("%s\n", fifo);
while (FCGX_Accept(&in, &out, &err, &envp) >= 0) {
char *contentLength = FCGX_GetParam("CONTENT_LENGTH", envp);
int len = 0;
++count;
if (contentLength != NULL)
len = strtol(contentLength, NULL, 10);
if (len <= 0) {
}
else {
int i, ch;
printf("POSTDATA=");
for (i = 0; i < len; i++) {
if ((ch = FCGX_GetChar(in)) < 0) {
FCGX_FPrintF(out,
"Error: Not enough bytes received on standard
input<p>\n");
break;
}
putchar(ch);
}
printf("\n");
}
PrintEnv(out, "Request environment", envp);
PrintEnv(out, "Initial environment", environ);
printf("<<EOF>>\n");
fflush (stdout);
fd_fifo=open(fifo, O_RDONLY);
if (fd_fifo != -1) {
while(1) {
/* in_count = read(fd_fifo,&buffer,1);
if (!in_count) {
break;
}
FCGX_PutChar(buffer, out);
*/
in_count = read(fd_fifo,&buffer,4096);
if (!in_count) {
break;
}
FCGX_PutStr(buffer,in_count,out);
}
close(fd_fifo);
}
else {
FCGX_FPrintF(out, "Could not open fifo-pipe");
}
} /* while */
unlink(fifo);
return 0;
} 7 6642
Sigfried Manner <si********@aon.at> wrote in
<3f***********************@newsreader01.highway.te lekom.at>: Hello NG!
I have following situation:
c-prg | webprg
<Warning: low topicality quotient> "c-prg" is a small c-programm which reads data from an fastCgi-Server and writes them to stdout.
<Severe warning: low topicality quotient>
The stdout is piped into webprg.
<Error: topicality quotient critical>
"webprg" is an 4th-GL Application that reads Data from StdIn and writes Data to an fifo-pipe.
<Red alert: Topicality-core destabilisation in progress>
"c-prg" reads data from the fifo-pipe and writes them back to the FastCGI-Server.
<Danger: Topicality-core containment field failed> Sometimes "webprg" stopps for different reasons. But "c-prg" is still alive and the Fast-CGI-Server has no reason to restart the process-chain.
<BOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOM>
<SNIPped question and *nixish code>
Please ask in an ng appropriate for your problem. c.l.c discusses the
C language in its standardized (read: portable) flavours.
Sorry.
Irrwahn
PS: While reading the FAQ for c.l.c, what did made you think it's the
right place for your question?
--
If you don't care where you are, then you ain't lost.
On Mon, 01 Sep 2003 17:16:24 +0200
Irrwahn Grausewitz <ir*****@freenet.de> wrote: Sigfried Manner <si********@aon.at> wrote in Please ask in an ng appropriate for your problem. c.l.c discusses the C language in its standardized (read: portable) flavours.
Actually, he did about five minutes later. At least he didn't cross-post, which
would probably have resulted in extensive flaming and killfiling.
PS: While reading the FAQ for c.l.c, what did made you think it's the right place for your question?
Probably the part that said 'Please post endless moobs of nonstandard code so
others can flame you without hesitation'. I think that's in the ten commandments
of C as well somewhere...
--
char*x(c,k,s)char*k,*s;{if(!k)return*s-36?x(0,0,s+1):s;if(s)if(*s)c=10+(c?(x(
c,k,0),x(c,k+=*s-c,s+1),*k):(x(*s,k,s+1),0));else c=10;printf(&x(~0,0,k)[c-~-
c+"1"[~c<-c]],c);}main(){x(0,"^[kXc6]dn_eaoh$%c","-34*1'.+(,03#;+,)/'///*");}
Irrwahn Grausewitz wrote: Please ask in an ng appropriate for your problem. c.l.c discusses the C language in its standardized (read: portable) flavours.
Sorry and Thanks!
Sig
Pieter Droogendijk <gi*@binky.homeunix.org> wrote in
<20030901172746.176548a5.gi*@binky.homeunix.org> : PS: While reading the FAQ for c.l.c, what did made you think it's the right place for your question? Probably the part that said 'Please post endless moobs of nonstandard code so others can flame you without hesitation'. I think that's in the ten commandments of C as well somewhere...
Yup, right next to 'Write ++i=i++; 5 times a day and be proud of it.'.
--
It is not necessary to understand things
in order to argue about them.
Irrwahn Grausewitz <ir*****@freenet.de> scribbled the following: Pieter Droogendijk <gi*@binky.homeunix.org> wrote in <20030901172746.176548a5.gi*@binky.homeunix.org> : PS: While reading the FAQ for c.l.c, what did made you think it's the right place for your question? Probably the part that said 'Please post endless moobs of nonstandard code so others can flame you without hesitation'. I think that's in the ten commandments of C as well somewhere...
Yup, right next to 'Write ++i=i++; 5 times a day and be proud of it.'.
Be proud? Of code that won't even compile? Or are you thinking of C++?
In C that should probably be "Write i=i++; 5 times a day and be proud of
it".
--
/-- Joona Palaste (pa*****@cc.helsinki.fi) ---------------------------\
| Kingpriest of "The Flying Lemon Tree" G++ FR FW+ M- #108 D+ ADA N+++|
| http://www.helsinki.fi/~palaste W++ B OP+ |
\----------------------------------------- Finland rules! ------------/
"That's no raisin - it's an ALIEN!"
- Tourist in MTV's Oddities
Irrwahn Grausewitz wrote: Pieter Droogendijk <gi*@binky.homeunix.org> wrote in <20030901172746.176548a5.gi*@binky.homeunix.org> : PS: While reading the FAQ for c.l.c, what did made you think it's the right place for your question? Probably the part that said 'Please post endless moobs of nonstandard code so others can flame you without hesitation'. I think that's in the ten commandments of C as well somewhere...
Yup, right next to 'Write ++i=i++; 5 times a day and be proud of it.'.
To be honest, i am not a c-programmer.
I?m developing business-applications since 15 years and (thank god!) i never
had the need to use os-system-near languages ;-)
Cheers!
Sig
Joona I Palaste <pa*****@cc.helsinki.fi> wrote in
<bi**********@oravannahka.helsinki.fi>: Yup, right next to 'Write ++i=i++; 5 times a day and be proud of it.'.
Be proud? Of code that won't even compile? Or are you thinking of C++? In C that should probably be "Write i=i++; 5 times a day and be proud of it".
Ah, you noticed the subtle humor. :)
--
It is not necessary to understand things
in order to argue about them. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Fabio Pliger |
last post by:
Hi,
is it possibile, in python, to check for an already running instance of an
application?
My problem is that, if my program i running and the user relaunch it, i
don't want to open a new...
|
by: McBooCzech |
last post by:
Hi all,
I am trying to use subprocess module on Linux/Python-2.4.1, but I can't
dig throught.
I need to call executable which needs two parameters to be ginven (the
serial port and the file...
|
by: Uri Nix |
last post by:
Hi all,
I've been trying to use (Python 2.4 on WinXP) the subprocess module to
execute a shell command (nmake in this case), and pass its output to a
higher level.
Using the following...
|
by: tomek |
last post by:
Hello
I got client-server application, client working in linux - server in
windows, but it doesn't matter. I want keeping connection for long time
and make reconnections in linux client, for...
|
by: Mike |
last post by:
Open source programs in general suck pretty bad also. Here are some
loose facts regarding why projects like Linux, PHP, MYSQL, and
other open source programs suck:
- Linux is simply a clone of...
|
by: Michael Ulmann |
last post by:
Hello All,
How can i check in a static class if a session with known id is still alive
or not?
Thanks in advance
Regards,
Michael
|
by: Thomas Dybdahl Ahle |
last post by:
Hi, When I do a small program like
from subprocess import Popen
popen = Popen()
from time import sleep
sleep(100)
start it and kill it, the ping process lives on.
Is there a way to ensure...
|
by: idzwan.nizam |
last post by:
Hi there,
I'm a new user. What library should I use so that I can launch program
in linux using python? Thank you in advance.
|
by: gregpinero |
last post by:
Let's say I have this Python file called loop.py:
import sys
print 'hi'
sys.stdout.flush()
while 1:
pass
And I want to call it from another Python process and read the value
'hi'. How...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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: 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...
|
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: 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...
| |