The following code doesn't give me any problem in Linux. But it is not that case when I run it in Mac OS 10.8.

I am wondering if I have done something wring about redirect the stderr and stdout. Is there any specific thing I need to know when doing this in Mac?

Code:
void
Code:
 start_server ( ) {
Code:


 char cmd[ MAX_BUF ];
	memset( cmd, 0, MAX_BUF );
	sprintf( cmd, "./x11vnc -storepasswd %s ", "./output/x11vnc.passwd" );
	system(cmd);
	memset( cmd, 0, MAX_BUF );
	sprintf( cmd, "./x11vnc -rfbauth %s -display :0", "./output/x11vnc.passwd" );

/* Redirect standard output to file */

 if( stdoutfp != NULL ) {
		fclose( stdoutfp );
		stdoutfp = NULL;
	}


	freopen( OUT_X11VNCOUT, "w", stdout );

	if( stdoutfp == NULL ){
		printf("Could not redirect output for X11 VNC Server.c\n");
		return;
	}
	printf("successfuln\n");
/* Redirect standard error to file */

	if( stderrfp != NULL ) {
		fclose( stderrfp );
		stdoutfp = NULL;
	}

	stderrfp = freopen( OUT_X11VNCERR, "w", stderr );
	if( stderrfp == NULL ){
		printf("Could not redirect output for X11 VNC Server.c\n");
		return;
	}
	freopen( OUT_X11VNCERR, "w", stderr );
	
        /* Start x11vnc */
#ifdef DEBUG
	printf( "DEBUG RDP: %s \n", cmd );
#endif
	x11vncfp = popen( cmd, "w" );
} /* end of start_server() */