I have a c program that launched by system call rsh in this way
system(" rsh -l $DTT $CTT './script.sh' ");
$DTT and $CTT are enviornment variable where i load in them the user and host name strings
when the c program is normal, the rsh work good, but when i trasform the c program in a daemon and next I execute it, the process rsh stay locked in the ubuntu system manager and waste a lot of CPU resources, rsh work at half, it execute the operation buty it stay blocked.
The code for transform my c program that use rsh is this below.
pid_t process_id = 0;
pid_t sid = 0;
//Crea processo figlio
process_id = fork();
// Indica il fallimento della fork()
if (process_id < 0)
{
printf("fork failed!\n");
// ritorna fallimento nello stato di uscita
exit(1);
}
// PROCESSO PADRE. Occore ucciderlo.
if (process_id > 0)
{
printf("process_id of child process %d \n", process_id);
// ritorna successo nello stato di uscita
exit(0);
}
//unmask the file mode
umask(0);
//setta nuova sessione
sid = setsid();
if(sid < 0)
{
// Return failure
exit(1);
}
// Chiude gli sdandard INPUT,OUTPUT e di ERRORE stdin. stdout and stderr
close(STDIN_FILENO);
close(STDOUT_FILENO);
close(STDERR_FILENO);
PROBLEM SOLVED! I redirect the standard output in a file and rsh don't give me any problems!