aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Grothoff <grothoff@gnunet.org>2022-07-21 12:30:22 +0200
committerChristian Grothoff <grothoff@gnunet.org>2022-07-21 12:31:40 +0200
commit63802d7241f06d04096d84bcd4dc49d7449293d8 (patch)
treeeb76791c53868898604c5edb64f6e5890f3cc1fd /src
parent3e4b81055b8df52d44861a5e40c148213509d0e5 (diff)
downloadgnunet-63802d7241f06d04096d84bcd4dc49d7449293d8.tar.gz
gnunet-63802d7241f06d04096d84bcd4dc49d7449293d8.zip
do not crash if psql is interrupted with CTRL-C
Diffstat (limited to 'src')
-rw-r--r--src/pq/pq_connect.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/src/pq/pq_connect.c b/src/pq/pq_connect.c
index 5fea994ef..a8c552407 100644
--- a/src/pq/pq_connect.c
+++ b/src/pq/pq_connect.c
@@ -150,6 +150,7 @@ apply_patch (struct GNUNET_PQ_Context *db,
150 unsigned long code; 150 unsigned long code;
151 size_t slen = strlen (load_path) + 10; 151 size_t slen = strlen (load_path) + 10;
152 char buf[slen]; 152 char buf[slen];
153 enum GNUNET_GenericReturnValue ret;
153 154
154 GNUNET_snprintf (buf, 155 GNUNET_snprintf (buf,
155 sizeof (buf), 156 sizeof (buf),
@@ -180,10 +181,21 @@ apply_patch (struct GNUNET_PQ_Context *db,
180 "psql"); 181 "psql");
181 return GNUNET_SYSERR; 182 return GNUNET_SYSERR;
182 } 183 }
183 GNUNET_assert (GNUNET_OK == 184 ret = GNUNET_OS_process_wait_status (psql,
184 GNUNET_OS_process_wait_status (psql, 185 &type,
185 &type, 186 &code);
186 &code)); 187 if (GNUNET_OK != ret)
188 {
189 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
190 "psql on file %s did not finish, killed it!\n",
191 buf);
192 /* can happen if we got a signal, like CTRL-C, before
193 psql was complete */
194 (void) GNUNET_OS_process_kill (psql,
195 SIGKILL);
196 GNUNET_OS_process_destroy (psql);
197 return GNUNET_SYSERR;
198 }
187 GNUNET_OS_process_destroy (psql); 199 GNUNET_OS_process_destroy (psql);
188 if ( (GNUNET_OS_PROCESS_EXITED != type) || 200 if ( (GNUNET_OS_PROCESS_EXITED != type) ||
189 (0 != code) ) 201 (0 != code) )