File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -674,6 +674,15 @@ static void sanitize_stdfds(void)
674
674
close (fd );
675
675
}
676
676
677
+ static void store_pid (const char * path )
678
+ {
679
+ FILE * f = fopen (path , "w" );
680
+ if (!f )
681
+ die ("cannot open pid file %s: %s" , path , strerror (errno ));
682
+ fprintf (f , "%d\n" , getpid ());
683
+ fclose (f );
684
+ }
685
+
677
686
static int serve (int port )
678
687
{
679
688
int socknum , * socklist ;
@@ -689,6 +698,7 @@ int main(int argc, char **argv)
689
698
{
690
699
int port = DEFAULT_GIT_PORT ;
691
700
int inetd_mode = 0 ;
701
+ const char * pid_file = NULL ;
692
702
int i ;
693
703
694
704
/* Without this we cannot rely on waitpid() to tell
@@ -753,6 +763,10 @@ int main(int argc, char **argv)
753
763
user_path = arg + 12 ;
754
764
continue ;
755
765
}
766
+ if (!strncmp (arg , "--pid-file=" , 11 )) {
767
+ pid_file = arg + 11 ;
768
+ continue ;
769
+ }
756
770
if (!strcmp (arg , "--" )) {
757
771
ok_paths = & argv [i + 1 ];
758
772
break ;
@@ -787,5 +801,8 @@ int main(int argc, char **argv)
787
801
788
802
sanitize_stdfds ();
789
803
804
+ if (pid_file )
805
+ store_pid (pid_file );
806
+
790
807
return serve (port );
791
808
}
You can’t perform that action at this time.
0 commit comments