From: "Mariano Moreyra" <moremari@aca.org.ar>
To: 'Jorge Opaso Pazos' <jopaso@trofeospazos.com>,
linux-c-programming@vger.kernel.org
Subject: RE: Question!
Date: Fri, 5 Sep 2003 11:58:18 -0300 [thread overview]
Message-ID: <000101c373be$24f4a860$0b04a8c0@aca.org.ar> (raw)
In-Reply-To: <3F580E34.8090905@trofeospazos.com>
-----Mensaje original-----
De: linux-c-programming-owner@vger.kernel.org
[mailto:linux-c-programming-owner@vger.kernel.org]En nombre de Jorge
Opaso Pazos
Enviado el: Viernes, 05 de Septiembre de 2003 01:17
Para: linux-c-programming@vger.kernel.org
Asunto: Re: Question!
Mariano Moreyra wrote:
> The problem is that the child is waiting for the script to finish (the one
> that start mysqld) so the child sends a response to the client telling him
> that the script finished ok (or not).
> So, if I close the socket, the child can't send the response.
> I tried to find a solution to this situation, but the client needs to know
> the exit status of the script.
> The parent process has his own socket listening for incoming connections
and
> forks the childs. These childs accepts the connections on his own sockets,
> so childs doesn't inherit the parent's socket.
> It's ok to do that?? Or I'm doing something wrong with the sockets??
> Thanks a lot to all of you for your answers!!
>
> -----Mensaje original-----
> De: linux-c-programming-owner@vger.kernel.org
> [mailto:linux-c-programming-owner@vger.kernel.org]En nombre de Luciano
> Miguel Ferreira Rocha
> Enviado el: Jueves, 04 de Septiembre de 2003 14:54
> Para: Jorge Opaso Pazos
> CC: linux-c-programming@vger.kernel.org
> Asunto: Re: Question!
>
>
> On Thu, Sep 04, 2003 at 12:04:43PM -0400, Jorge Opaso Pazos wrote:
>
>>Mariano Moreyra wrote:
>>
>>>Hola!
>>>Te mando la seccion del programa que ejecuta el script en si.
>>>
>>>Este proceso lo unico que espera del script es que el mismo conteste con
>
> un
>
>>>"-" si hubo algun error o con un "+" si salio todo bien
>>>
>>>----------------------------------------------------------
>>> if(err==0) {
>>> pipe_in = popen(shell_cmd,"r");
>>> fgets(response,5,pipe_in);
>>>
>>> if(response[0]=='-') {
>>> err=1;
>>> } else if(response[0]=='+') {
>>> err=0;
>>> };
>>> while(fgets(response,5,pipe_in)) {
>>> };
>>> pclose(pipe_in);
>>> };
>>>-----------------------------------------------------------
>>>
>>>El script lo unico que hace es copiar algunos archivos y luego leventar
>
> el
>
>>>MySQL con el
>>>safe_mysqld
>>>
>>>Espero que esto sirva! Muchas gracias!!
>>>Saludos!!
>>>
>>>
>>>
>>>-----Mensaje original-----
>>>De: linux-c-programming-owner@vger.kernel.org
>>>[mailto:linux-c-programming-owner@vger.kernel.org]En nombre de Jorge
>>>Opaso Pazos
>>>Enviado el: Miércoles, 03 de Septiembre de 2003 18:09
>>>Para: linux-c-programming@vger.kernel.org
>>>Asunto: Re: Question!
>>>
>>>
>>>Mariano Moreyra wrote:
>>>
>>>
>>>>Hi!!
>>>>First...I'd like to know if there is any kind of digest on this list to
>>>
>>>see
>>>
>>>
>>>>old submited messages.
>>>>
>>>>Now...I have a little problem.
>>>>I have a process that is listening for incoming connections on a socket.
>>>>That process waits for a command and then
>>>>forks a child to run a bash script.
>>>>The problems is:
>>>> - When the bash script runs the safe_mysql script to run MySql
>>>> engine,
>>>
>>>it's
>>>
>>>
>>>>like the child process never ends.
>>>> And because of that, the parent can't close the connection with the
>>>>client socket.
>>>> - But if the bash script doesn't run the safe_mysql script...the
>>>> child
>>>>process dies successfully and everything end
>>>> Ok
>>>>
>>>>Sorry about my english, but I hope that I made my self clear....
>>>>Bye!
>>>>
>>>>-
>>>>To unsubscribe from this list: send the line "unsubscribe
>>>
>>>linux-c-programming" in
>>>
>>>
>>>>the body of a message to majordomo@vger.kernel.org
>>>>More majordomo info at http://vger.kernel.org/majordomo-info.html
>>>>
>>>
>>>
>>>envíame el script.
>>>
>>>-
>>>To unsubscribe from this list: send the line "unsubscribe
>>>linux-c-programming" in
>>>the body of a message to majordomo@vger.kernel.org
>>>More majordomo info at http://vger.kernel.org/majordomo-info.html
>>>
>>
>>English: I suspect that the problem is that safe_mysqld don't return
>>until mysqld ends.
>>Try to execute safe_mysqld in background in the shellscript:
>>
>> if ! pgrep mysqld
>> then
>> /usr/bin/safe_mysqld &
>> fi
>
> As the socket is inherited, the remote client will never exit.
> If the popen is after a fork(), then it doesn't matter if safe_mysql
doesn't
> end, as the parent wouldn't be waiting on it.
>
> My bet is in the socket not being closed, either in the parent, child, or
> both, or before the execution of safe_mysql. (If mysqld inherits the
socket,
> then the connection won't close until mysqld does.)
>
>
>>Castellano: El problema debe ser que no termina safe_mydqld hasta que no
>>termina mysqld. Se podría solucionar llamando a safe_mysqld en
>>"background" de la forma anterior.
>
>
> Portugues: AH! that would be something :)
>
> Regards,
> Luciano Rocha
> -
> To unsubscribe from this list: send the line "unsubscribe
> linux-c-programming" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
> -
> To unsubscribe from this list: send the line "unsubscribe
linux-c-programming" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
>Hi Mariano, hi Luciano.
>When we make a concurrent server (a server that spawn a child process
>when accept return) always the parent have to close de socket returned
>by accept and the child have to close the socket that the server use to
>call accept (server socket).
I have to check if I'm closing the sockets in the right way...
>I you have to inform the client about the exit status of the script, the
>better way (I think) is to execute the script in the child with
>system(3), because you need the exit status of the script, not the
>output.
I tried to execute the script with system, but I don't know why I didn't
recieve the right exit status from the script. That's why i'm using popen
and getting the output.
> About the safe_mysqld, you must send it to bg.
The script is running safe_mysqld on bg, but that seems to be the problem.
Actually, if I'm connected to my linux box, via SecureCRT and run
safe_mysqld on background, when I exit from the console, with the exit
command or Ctrl-D, the SecureCRT connection never ends.
That's why I don't know if my problem really has a solution hehe :)
But I'll keep trying all your recomendations to see what happens.
Thanks again!!
>Luciano, I've never heard the lsof command, thanks.
About lsof ... I don't know if it comes with all Linux distributions, but in
my case it does (Linux Redhat 7.2)
-
To unsubscribe from this list: send the line "unsubscribe
linux-c-programming" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
-
To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2003-09-05 14:58 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-09-03 18:19 Question! Mariano Moreyra
2003-09-03 21:09 ` Question! Jorge Opaso Pazos
2003-09-04 13:51 ` Question! Mariano Moreyra
2003-09-04 14:05 ` Question! Luciano Miguel Ferreira Rocha
2003-09-04 14:28 ` Question! Mariano Moreyra
2003-09-04 16:04 ` Question! Jorge Opaso Pazos
2003-09-04 17:53 ` Question! Luciano Miguel Ferreira Rocha
2003-09-04 18:41 ` Question! Mariano Moreyra
2003-09-04 19:32 ` Question! Luciano Miguel Ferreira Rocha
2003-09-05 4:16 ` Question! Jorge Opaso Pazos
2003-09-05 14:58 ` Mariano Moreyra [this message]
2003-09-04 14:01 ` Question! Luciano Miguel Ferreira Rocha
2003-09-04 17:20 ` Question! Jorge Opaso Pazos
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='000101c373be$24f4a860$0b04a8c0@aca.org.ar' \
--to=moremari@aca.org.ar \
--cc=jopaso@trofeospazos.com \
--cc=linux-c-programming@vger.kernel.org \
--cc=mariano_moreyra@aca.org.ar \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).