🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: es.comp.os.linux.programacion
Article #15055

Re: Programacion de demonios

#15055
From: Mario Teijeiro Otero
Date: Tue, 22 Aug 2000 00:00
51 lines
2332 bytes
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

"J.A. Gutierrez" <spd@daphne.cps.unizar.es> writes:

> Guido Reina <guido.reina@tecnet-sports.com> wrote:
> 
> :     Me gustaria saber como se programa un demonio que se pueda lanzar desde
> : un terminal, se quede residente, y se mantenga funcionando aunque se mate al
> : terminal. Que se independice del terminal.
> 
> #include <stdio.h>
> #include <sys/types.h>
> #include <unistd.h>
> 
> int main(int argc, char **argv, char **envp)
> {
> 	if (fork())
> 	{
> 		exit(0);
> 	}
> 
> 	printf("%d\n",getpid()); 
> 	sleep( atol( argv[1] ));
> 	exit(0);
> }
> 
> 	para hacerlo bien, hay que cerrar el std* y demas, pero
> 	bueno, ya ves por donde va la cosa.

esto as� no vale, ya que si cierras el terminal de donde lo lanzaste, el 
programa tb se sale, es necesario salir de las sesi�n desde el programa, 
es decir, hace como un nohup. 
La respuesta est� en un libro de programaci�n avanzada de unix.
Saludos
- -- 
Donde este una buena corrida que se quite el f�tbol... y los toros.

====================================================================
Mario Teijeiro Otero           mailto:asimovi at teleline dot es         
Powered by Hispafuentes 7.0    clave: correo con Asunto: "[PGPKEY]"
Usr. Reg. 122438               o en http://www.terra.es/personal2/asimovi 
====================================================================
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.1 (GNU/Linux)
Comment: Processed by Mailcrypt 3.5.5 and Gnu Privacy Guard <http://www.gnupg.org/>

iD8DBQE5ouf+MKsc+XeZcdwRAvpzAJ90l1MGkI0A/4FQMIyEk3J0hiXP7ACcCH4K
TqsJSvLj79Z6cTPuJZVabJU=
=JXvV
-----END PGP SIGNATURE-----
Technical Details
Message-ID: <m3wvh9dnnj.fsf@asimovi.localdomain>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <8nr6fh$11h4t11@SGI3651ef0.iddeo.es> <8ntmc3$c1v$2@news.unizar.es>

Show Full Headers
Complete Article Headers
X-Google-Language: SPANISH,ASCII
X-Google-Thread: f86c8,a5c338c109de3a74
X-Google-Attributes: gidf86c8,public
From: Mario Teijeiro Otero <asimovi@teleline.es>
Subject: Re: Programacion de demonios
Date: 2000/08/22
Message-ID: <m3wvh9dnnj.fsf@asimovi.localdomain>
X-Deja-AN: 661603997
Content-Transfer-Encoding: 8bit
References: <8nr6fh$11h4t11@SGI3651ef0.iddeo.es> <8ntmc3$c1v$2@news.unizar.es>
Organization: Telefonica Transmision de Datos
Content-Type: text/plain; charset=iso-8859-1
User-Agent: Gnus/5.0806 (Gnus v5.8.6) Emacs/20.5
Mime-Version: 1.0
Newsgroups: es.comp.os.linux.programacion