Question!
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!
Quoted 17 lines · Mariano Moreyra
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 thesafe_mysqlscript 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 thesafe_mysqlscript...the child
process dies successfully and everything end
Ok
Quoted 8 lines
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 [email protected]
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 [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
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 elsafe_mysqld
Espero que esto sirva! Muchas gracias!!
Saludos!!
-----Mensaje original-----
De: [email protected] [mailto:[email protected]]En nombre de Jorge Opaso Pazos
Enviado el: Miércoles, 03 de Septiembre de 2003 18:09
Para: [email protected]
Asunto: Re: Question!
Quoted 2 lines · Mariano Moreyra
Hi!!
First...I'd like to know if there is any kind of digest on this list to
see
Quoted 8 lines
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 thesafe_mysqlscript to run MySql engine,
it's
Quoted 7 lines
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 thesafe_mysqlscript...the child
process dies successfully and everything end
Ok
Quoted 5 lines
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
Quoted 3 lines
the body of a message to [email protected]
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 [email protected]
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 [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 20 lines · Mariano Moreyra
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); };
Quoted 8 lines
-----------------------------------------------------------
El script lo unico que hace es copiar algunos archivos y luego leventar el MySQL con el
safe_mysqldEspero que esto sirva! Muchas gracias!!
Saludos!!
Please, this is an international list, so write in english.
Are you closing the socket before de popen(3)? Make sure you do and that if this is a child to exit(2) after being done with the script.
Regards,
Luciano Rocha
Ok!!! First of all, Sorry for writting in spanish!
I'm not closing the socket in the child process...so I'll try that and see what happens.
Thanks a lot!!!
And sorry again!
-----Mensaje original-----
De: [email protected] [mailto:[email protected]]En nombre de Luciano Miguel Ferreira Rocha
Enviado el: Jueves, 04 de Septiembre de 2003 11:05
Para: [email protected]
CC: 'Jorge Opaso Pazos'; [email protected]
Asunto: Re: Question!
Quoted 4 lines · Mariano Moreyra
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
Quoted 16 lines
"-" 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); };
Quoted 8 lines
-----------------------------------------------------------
El script lo unico que hace es copiar algunos archivos y luego leventar el MySQL con el
safe_mysqldEspero que esto sirva! Muchas gracias!!
Saludos!!
Please, this is an international list, so write in english.
Are you closing the socket before de popen(3)? Make sure you do and that if this is a child to exit(2) after being done with the script.
Regards,
Luciano Rocha
-
To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 78 lines · Mariano Moreyra
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_mysqldEspero que esto sirva! Muchas gracias!!
Saludos!!-----Mensaje original-----
De: [email protected] [mailto:[email protected]]En nombre de Jorge Opaso Pazos
Enviado el: Miércoles, 03 de Septiembre de 2003 18:09
Para: [email protected]
Asunto: Re: Question!Quoted 2 lines · Mariano Moreyra
Hi!!
First...I'd like to know if there is any kind of digest on this list tosee
Quoted 8 lines
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 thesafe_mysqlscript to run MySql engine,it's
Quoted 7 lines
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 thesafe_mysqlscript...the child
process dies successfully and everything end
OkQuoted 5 lines
Sorry about my english, but I hope that I made my self clear.... Bye!
-
To unsubscribe from this list: send the line "unsubscribelinux-c-programming" in
Quoted 3 lines
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 8 lines
envíame el script.
-
To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
the body of a message to [email protected]
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
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.
-
To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 90 lines · Jorge Opaso Pazos
Quoted 80 lines · Mariano Moreyra
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_mysqldEspero que esto sirva! Muchas gracias!!
Saludos!!-----Mensaje original-----
De: [email protected] [mailto:[email protected]]En nombre de Jorge Opaso Pazos
Enviado el: Miércoles, 03 de Septiembre de 2003 18:09
Para: [email protected]
Asunto: Re: Question!Quoted 2 lines · Mariano Moreyra
Hi!!
First...I'd like to know if there is any kind of digest on this list tosee
Quoted 9 lines
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 thesafe_mysqlscript to run MySql engine,it's
Quoted 8 lines
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 thesafe_mysqlscript...the child
process dies successfully and everything end
OkQuoted 5 lines
Sorry about my english, but I hope that I made my self clear.... Bye!
-
To unsubscribe from this list: send the line "unsubscribelinux-c-programming" in
Quoted 3 lines
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.htmlQuoted 8 lines
envíame el script.
-
To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 8 lines
English: I suspect that the problem is that
safe_mysqlddon't return until mysqld ends.
Try to executesafe_mysqldin 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.)
Quoted 3 lines
Castellano: El problema debe ser que no termina
safe_mydqldhasta que no termina mysqld. Se podría solucionar llamando asafe_mysqlden "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 [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
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: [email protected] [mailto:[email protected]]En nombre de Luciano Miguel Ferreira Rocha
Enviado el: Jueves, 04 de Septiembre de 2003 14:54
Para: Jorge Opaso Pazos
CC: [email protected]
Asunto: Re: Question!
Quoted 5 lines · Jorge Opaso Pazos
Quoted 4 lines · Mariano Moreyra
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
Quoted 18 lines
Quoted 18 lines
"-" 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);};
-----------------------------------------------------------
Quoted 1 line
Quoted 1 line
El script lo unico que hace es copiar algunos archivos y luego leventar
el
Quoted 66 lines
Quoted 57 lines
MySQL con el
safe_mysqldEspero que esto sirva! Muchas gracias!!
Saludos!!-----Mensaje original-----
De: [email protected] [mailto:[email protected]]En nombre de Jorge Opaso Pazos
Enviado el: Miércoles, 03 de Septiembre de 2003 18:09
Para: [email protected]
Asunto: Re: Question!Quoted 2 lines · Mariano Moreyra
Hi!!
First...I'd like to know if there is any kind of digest on this list tosee
Quoted 9 lines
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 thesafe_mysqlscript to run MySql engine,it's
Quoted 8 lines
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 thesafe_mysqlscript...the child
process dies successfully and everything end
OkQuoted 5 lines
Sorry about my english, but I hope that I made my self clear.... Bye!
-
To unsubscribe from this list: send the line "unsubscribelinux-c-programming" in
Quoted 3 lines
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.htmlQuoted 8 lines
envíame el script.
-
To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 8 lines
English: I suspect that the problem is that
safe_mysqlddon't return until mysqld ends.
Try to executesafe_mysqldin 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.)
Quoted 3 lines
Castellano: El problema debe ser que no termina
safe_mydqldhasta que no termina mysqld. Se podría solucionar llamando asafe_mysqlden "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 [email protected]
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 [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 3 lines · Mariano Moreyra
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).
Well, I don't know what safe_mysqld script is that. The one on my system doesn't end.
Check that yours do, by running it on a normal console.
If it does end, then I have the following questions: are you closing the socket after the pclose and/or exiting the child?
If so, then I guess your problem lies with popen. popen doesn't close the other file descriptors, so the socket gets inherited. To see if that's the true cause, start mysql through your interface and do a lsof -c mysql.
If the socket connection shows up, then you have to change your popen, either by implementing it with pipe(2), fork(2), dup2(2), close(2), exec* and _exit(2). Or by forking another child to do the close(sock); popen, etc., and use the exit status of that child for indication of success or failure.
Regards,
Luciano Rocha
Quoted 158 lines · Mariano Moreyra
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: [email protected] [mailto:[email protected]]En nombre de Luciano Miguel Ferreira Rocha
Enviado el: Jueves, 04 de Septiembre de 2003 14:54
Para: Jorge Opaso Pazos
CC: [email protected]
Asunto: Re: Question!Quoted 6 lines · Jorge Opaso Pazos
Quoted 4 lines · Mariano Moreyra
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
Quoted 18 lines
Quoted 18 lines
"-" 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);};
-----------------------------------------------------------Quoted 1 line
Quoted 1 line
El script lo unico que hace es copiar algunos archivos y luego leventar
el
Quoted 70 lines
Quoted 61 lines
MySQL con el
safe_mysqldEspero que esto sirva! Muchas gracias!!
Saludos!!-----Mensaje original-----
De: [email protected] [mailto:[email protected]]En nombre de Jorge Opaso Pazos
Enviado el: Miércoles, 03 de Septiembre de 2003 18:09
Para: [email protected]
Asunto: Re: Question!Quoted 2 lines · Mariano Moreyra
Hi!!
First...I'd like to know if there is any kind of digest on this list tosee
Quoted 9 lines
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 thesafe_mysqlscript to run MySql engine,it's
Quoted 8 lines
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 thesafe_mysqlscript...the child
process dies successfully and everything end
OkQuoted 5 lines
Sorry about my english, but I hope that I made my self clear.... Bye!
-
To unsubscribe from this list: send the line "unsubscribelinux-c-programming" in
Quoted 3 lines
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.htmlQuoted 8 lines
envíame el script.
-
To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.htmlQuoted 8 lines
English: I suspect that the problem is that
safe_mysqlddon't return until mysqld ends.
Try to executesafe_mysqldin background in the shellscript:if ! pgrep mysqld
then
/usr/bin/safe_mysqld&
fiAs the socket is inherited, the remote client will never exit. If the popen is after a
fork(), then it doesn't matter ifsafe_mysqldoesn'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.)Quoted 3 lines
Castellano: El problema debe ser que no termina
safe_mydqldhasta que no termina mysqld. Se podría solucionar llamando asafe_mysqlden "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 [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 5 lines
-
To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in the body of a message to [email protected]
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 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. About the safe_mysqld, you must send it to bg.
Luciano, I've never heard the lsof command, thanks.
-
To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
-----Mensaje original-----
De: [email protected] [mailto:[email protected]]En nombre de Jorge Opaso Pazos
Enviado el: Viernes, 05 de Septiembre de 2003 01:17
Para: [email protected]
Asunto: Re: Question!
Quoted 7 lines · Mariano Moreyra
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
Quoted 122 lines
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: [email protected] [mailto:[email protected]]En nombre de Luciano Miguel Ferreira Rocha
Enviado el: Jueves, 04 de Septiembre de 2003 14:54
Para: Jorge Opaso Pazos
CC: [email protected]
Asunto: Re: Question!Quoted 6 lines · Jorge Opaso Pazos
Quoted 4 lines · Mariano Moreyra
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
Quoted 18 lines
Quoted 18 lines
"-" 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);};
-----------------------------------------------------------Quoted 1 line
Quoted 1 line
El script lo unico que hace es copiar algunos archivos y luego leventar
el
Quoted 74 lines
Quoted 61 lines
MySQL con el
safe_mysqldEspero que esto sirva! Muchas gracias!!
Saludos!!-----Mensaje original-----
De: [email protected] [mailto:[email protected]]En nombre de Jorge Opaso Pazos
Enviado el: Miércoles, 03 de Septiembre de 2003 18:09
Para: [email protected]
Asunto: Re: Question!Quoted 2 lines · Mariano Moreyra
Hi!!
First...I'd like to know if there is any kind of digest on this list tosee
Quoted 9 lines
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 thesafe_mysqlscript to run MySql engine,it's
Quoted 8 lines
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 thesafe_mysqlscript...the child
process dies successfully and everything end
OkQuoted 5 lines
Sorry about my english, but I hope that I made my self clear.... Bye!
-
To unsubscribe from this list: send the line "unsubscribelinux-c-programming" in
Quoted 3 lines
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.htmlQuoted 8 lines
envíame el script.
-
To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.htmlEnglish: I suspect that the problem is that
safe_mysqlddon't return until mysqld ends.
Try to executesafe_mysqldin background in the shellscript:
Quoted 7 lines
Quoted 4 lines
if ! pgrep mysqld
then
/usr/bin/safe_mysqld&
fiAs the socket is inherited, the remote client will never exit. If the popen is after a
fork(), then it doesn't matter ifsafe_mysql
doesn't
Quoted 4 lines
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,
Quoted 18 lines
then the connection won't close until mysqld does.)
Quoted 3 lines
Castellano: El problema debe ser que no termina
safe_mydqldhasta que no termina mysqld. Se podría solucionar llamando asafe_mysqlden "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 [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 2 lines
-
To unsubscribe from this list: send the line "unsubscribe
linux-c-programming" in
Quoted 10 lines
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.htmlHi 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...
Quoted 4 lines
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.
Quoted 1 line
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!!
Quoted 1 line
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 [email protected]
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 [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 4 lines · Mariano Moreyra
Hi!!
First...I'd like to know if there is any kind of digest on this list to see old submited messages.
Quoted 13 lines
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 thesafe_mysqlscript 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 thesafe_mysqlscript...the child
process dies successfully and everything end
Ok
Hola,
Your problem should be the socket inherited by the child that will run the script. I suppose the child doesn't need it, does it?
So, close it and redirect /dev/null to stdin, stdout and stderr:
if ((fork() == 0) { /* child */
int fd;
close(sock);
fd = open("/dev/null", O_RDONLY);
if (fd != 0) {
dup2(fd, 0);
close(fd);
}
fd = open("/dev/null", O_WRONLY);
if (fd != 1) {
dup2(fd, 1);
close(fd);
}
fd = open("/dev/null", O_WRONLY);
if (fd != 2) {
dup2(fd, 2);
close(fd);
}
execl("/usr/bin/safe_mysqld", "safe_mysqld", 0);
_exit(1);
}Regards,
Luciano Rocha
Quoted 48 lines · Luciano Miguel Ferreira Rocha
Quoted 4 lines · Mariano Moreyra
Hi!!
First...I'd like to know if there is any kind of digest on this list to see old submited messages.Quoted 13 lines
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 thesafe_mysqlscript 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 thesafe_mysqlscript...the child
process dies successfully and everything end
OkHola,
Your problem should be the socket inherited by the child that will run the script. I suppose the child doesn't need it, does it?
So, close it and redirect
/dev/nullto stdin, stdout and stderr:
if ((fork()== 0) { /* child */int fd; close(sock); fd = open("/dev/null", O_RDONLY); if (fd != 0) { dup2(fd, 0); close(fd); } fd = open("/dev/null", O_WRONLY); if (fd != 1) { dup2(fd, 1); close(fd); } fd = open("/dev/null", O_WRONLY); if (fd != 2) { dup2(fd, 2); close(fd); } execl("/usr/bin/safe_mysqld", "safe_mysqld", 0); _exit(1); }
Quoted 7 lines
Regards,
Luciano Rocha
-
To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Hi, Luciano:
popen redirect the stdout of the child to the stream created if the call is in the form:
FILE f = popen("cmd", "r");Bye.