Fixes #1
This commit is contained in:
		
							
								
								
									
										35
									
								
								xwinwrap.c
									
									
									
									
									
								
							
							
						
						
									
										35
									
								
								xwinwrap.c
									
									
									
									
									
								
							@@ -150,6 +150,7 @@ static void usage (void)
 | 
			
		||||
            -o      - Opacity value between 0 to 1 (ex: -o 0.20)\n \
 | 
			
		||||
            -sh     - Shape of window (choose between rectangle, circle or triangle. Default is rectangle)\n \
 | 
			
		||||
            -ov     - Set override_redirect flag (For seamless desktop background integration in non-fullscreenmode)\n \
 | 
			
		||||
            -d      - Daemonize\n \
 | 
			
		||||
            -debug  - Enable debug messages\n");
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -283,6 +284,7 @@ int main(int argc, char **argv)
 | 
			
		||||
    bool above = false;
 | 
			
		||||
    bool skip_taskbar = false;
 | 
			
		||||
    bool skip_pager = false;
 | 
			
		||||
    bool daemonize = false;
 | 
			
		||||
 | 
			
		||||
    win_shape   shape = SHAPE_RECT;
 | 
			
		||||
    Pixmap      mask;
 | 
			
		||||
@@ -366,6 +368,10 @@ int main(int argc, char **argv)
 | 
			
		||||
        {
 | 
			
		||||
            debug = true;
 | 
			
		||||
        }
 | 
			
		||||
        else if (strcmp (argv[i], "-d") == 0)
 | 
			
		||||
        {
 | 
			
		||||
            daemonize = true;
 | 
			
		||||
        }
 | 
			
		||||
        else if (strcmp (argv[i], "--") == 0)
 | 
			
		||||
        {
 | 
			
		||||
            break;
 | 
			
		||||
@@ -377,6 +383,35 @@ int main(int argc, char **argv)
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if (daemonize)
 | 
			
		||||
    {
 | 
			
		||||
        pid_t process_id = 0;
 | 
			
		||||
        pid_t sid = 0;
 | 
			
		||||
        process_id = fork();
 | 
			
		||||
        if (process_id < 0)
 | 
			
		||||
        {
 | 
			
		||||
            fprintf(stderr, "fork failed!\n");
 | 
			
		||||
            exit(1);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (process_id > 0)
 | 
			
		||||
        {
 | 
			
		||||
            fprintf(stderr, "pid of child process %d \n", process_id);
 | 
			
		||||
            exit(0);
 | 
			
		||||
        }
 | 
			
		||||
        umask(0);
 | 
			
		||||
        sid = setsid();
 | 
			
		||||
        if (sid < 0)
 | 
			
		||||
        {
 | 
			
		||||
            exit(1);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        chdir("/");
 | 
			
		||||
        close(STDIN_FILENO);
 | 
			
		||||
        close(STDOUT_FILENO);
 | 
			
		||||
        close(STDERR_FILENO);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    for (i = i + 1; i < argc; i++)
 | 
			
		||||
    {
 | 
			
		||||
        if (strcmp (argv[i], "WID") == 0)
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user