~ubuntu-branches/ubuntu/maverick/gnome-keyring/maverick-proposed

« back to all changes in this revision

Viewing changes to daemon/gkr-daemon.c

  • Committer: Bazaar Package Importer
  • Author(s): Sebastien Bacher
  • Date: 2009-03-02 17:00:10 UTC
  • mto: (2.2.1 sid)
  • mto: This revision was merged to the branch mainline in revision 71.
  • Revision ID: james.westby@ubuntu.com-20090302170010-1bakcvrq713wq2q0
Tags: upstream-2.25.92
ImportĀ upstreamĀ versionĀ 2.25.92

Show diffs side-by-side

added added

removed removed

Lines of Context:
579
579
                exit (0);
580
580
        }
581
581
        
582
 
        if (!run_daemonized) 
583
 
                return;
584
 
        
585
 
        /* Double fork if need to daemonize properly */
586
 
        pid = fork ();
587
 
        
588
 
        if (pid != 0) {
589
 
 
590
 
                /* Here we are in the intermediate child process */
591
 
                        
592
 
                /* 
593
 
                 * This process exits, so that the final child will inherit 
594
 
                 * init as parent to avoid zombies
595
 
                 */
596
 
                if (pid == -1)
597
 
                        exit (1);
598
 
 
599
 
                /* We've done two forks. Now we know the PID */
600
 
                print_environment (pid);
601
 
                        
602
 
                /* The intermediate child exits */
603
 
                exit (0);
 
582
        if (run_daemonized) { 
 
583
                
 
584
                /* Double fork if need to daemonize properly */
 
585
                pid = fork ();
 
586
        
 
587
                if (pid != 0) {
 
588
 
 
589
                        /* Here we are in the intermediate child process */
 
590
                                
 
591
                        /* 
 
592
                         * This process exits, so that the final child will inherit 
 
593
                         * init as parent to avoid zombies
 
594
                         */
 
595
                        if (pid == -1)
 
596
                                exit (1);
 
597
        
 
598
                        /* We've done two forks. Now we know the PID */
 
599
                        print_environment (pid);
 
600
                                
 
601
                        /* The intermediate child exits */
 
602
                        exit (0);
 
603
                }
 
604
                
604
605
        }
605
606
 
606
 
        /* Here we are in the resulting daemon process. */
 
607
        /* Here we are in the resulting daemon or background process. */
607
608
 
608
609
        for (i = 0; i < 3; ++i) {
609
610
                fd = open ("/dev/null", O_RDONLY);
612
613
        }
613
614
}
614
615
 
615
 
gboolean
616
 
gkr_daemon_complete_initialization(void)
 
616
static gboolean
 
617
gkr_daemon_complete_initialization_steps (void)
617
618
{
618
 
        /*
619
 
         * Sometimes we don't initialize the full daemon right on 
620
 
         * startup. When run with --login is one such case.
621
 
         */
622
 
        
623
 
        if (initialization_completed) {
624
 
                g_message ("The daemon was already initialized.");
625
 
                return TRUE;
626
 
        }
627
 
        
628
619
        /* Initialize new style PKCS#11 components */
629
620
        if (!gkr_pkcs11_daemon_initialize ())
630
621
                return FALSE;
649
640
        return TRUE;
650
641
}
651
642
 
 
643
gboolean
 
644
gkr_daemon_complete_initialization (void)
 
645
{
 
646
        /*
 
647
         * Sometimes we don't initialize the full daemon right on 
 
648
         * startup. When run with --login is one such case.
 
649
         */
 
650
        
 
651
        if (initialization_completed) {
 
652
                g_message ("The daemon was already initialized.");
 
653
                return TRUE;
 
654
        }
 
655
 
 
656
        /* Set this early so that two initializations don't overlap */
 
657
        initialization_completed = TRUE;
 
658
 
 
659
        /* But then set it back if initializing fails */
 
660
        initialization_completed = gkr_daemon_complete_initialization_steps ();
 
661
 
 
662
        return initialization_completed;
 
663
}
 
664
 
652
665
int
653
666
main (int argc, char *argv[])
654
667
{