@@ -1042,12 +1042,16 @@ static void log_warm_up(struct plugin *p)
10421042
10431043static void wait_and_check_bitcoind (struct plugin * p )
10441044{
1045- int in , from , status , ret ;
1045+ int in , from , status ;
10461046 pid_t child ;
10471047 const char * * cmd =
10481048 gather_args (bitcoind , "-rpcwait" , "getnetworkinfo" , NULL );
10491049 char * output = NULL ;
10501050
1051+ struct timers * timer = tal (cmd , struct timers );
1052+ timers_init (timer , time_mono ());
1053+ new_reltimer (timer , timer , time_from_sec (30 ), log_warm_up , p );
1054+
10511055 child = pipecmdarr (& in , & from , & from , cast_const2 (char * * , cmd ));
10521056
10531057 if (bitcoind -> rpcpass )
@@ -1066,32 +1070,18 @@ static void wait_and_check_bitcoind(struct plugin *p)
10661070
10671071 output = grab_fd (cmd , from );
10681072
1069- while ((ret = waitpid (child , & status , 0 )) < 0 && errno == EINTR )
1070- ;
1071- if (ret != child )
1072- bitcoind_failure (p , tal_fmt (bitcoind , "Waiting for %s: %s" ,
1073- cmd [0 ], strerror (errno )));
1073+ waitpid (child , & status , 0 );
1074+
10741075 if (!WIFEXITED (status ))
10751076 bitcoind_failure (p , tal_fmt (bitcoind , "Death of %s: signal %i" ,
10761077 cmd [0 ], WTERMSIG (status )));
10771078
1078- /* bitcoin/src/rpc/protocol.h:
1079- * RPC_IN_WARMUP = -28, //!< Client still warming up
1080- */
1081- if (WEXITSTATUS (status ) != 0 && WEXITSTATUS (status ) != 28 ) {
1082- if (WEXITSTATUS (status ) == 1 )
1083- bitcoind_failure (p ,
1084- "Could not connect to bitcoind using"
1085- " bitcoin-cli. Is bitcoind running?" );
1079+ if (WEXITSTATUS (status ) != 0 ) {
10861080 bitcoind_failure (p ,
10871081 tal_fmt (bitcoind , "%s exited with code %i: %s" ,
10881082 cmd [0 ], WEXITSTATUS (status ), output ));
10891083 }
10901084
1091- struct timers * timer = tal (cmd , struct timers );
1092- timers_init (timer , time_mono ());
1093- new_reltimer (timer , timer , time_from_sec (30 ), log_warm_up , p );
1094-
10951085 parse_getnetworkinfo_result (p , output );
10961086
10971087 tal_free (cmd );
0 commit comments