Re: daemon

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Tue, Apr 10, 2007 at 11:20:58AM +0530, Srinivas G. wrote:
> 	/* second child continues here */
> 	
> 	/* change the current working directory to root directory */
> 	chdir("/");	
> 	
> 	/* clearing the file mode creation mask to 0 */
> 	umask(0);	
> 

You forgot:

	close(0);
	close(1);
	close(2);

> 	/* undefined file descriptor should be closed */
> 	fileDesc=open("/dev/null",O_RDWR);	/* stdin */
> 	
> 	(void) dup(fileDesc);			/* stdout */
> 	
> 	(void) dup(fileDesc);			/* stderr */

Without the three close()s the above three lines will not work as
expected.


Erik

- -- 
They're all fools. Don't worry. Darwin may be slow, but he'll
eventually get them. -- Matthew Lammers in alt.sysadmin.recovery
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)

iD8DBQFGHJC9/PlVHJtIto0RAnF/AJsHpQx+EwNAqGUVlI1EvRAXf0MH6QCfTRr3
ptK7Wo+7R7xvSoKX8H1E61s=
=cjrE
-----END PGP SIGNATURE-----

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx
Please read the FAQ at http://kernelnewbies.org/FAQ


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux