+ char gw_id_str[16];
+ void *sprog;
+ size_t sprog_size;
+ int r;
+
+ sprintf (gw_id_str, "%d", gw_id);
+ r = gw_db_lookup (gw_db, gw_id_str, strlen(gw_id_str)+1,
+ &sprog, &sprog_size);
+ if (r != 1)
+ {
+ gw_log (GW_LOG_FATAL, prog, "gw_db_lookup %s", gw_id_str);
+ fatal("Internal error in server");
+ }
+ gw_log (GW_LOG_DEBUG|GW_LOG_ERRNO, prog, "open %s restart", clientp);
+ spawn (sprog, gw_id);
+ gw_log (GW_LOG_DEBUG, prog, "Synchronizing with client");
+ if ((linein = open(serverp, O_RDONLY)) < 0)
+ {
+ gw_log (GW_LOG_FATAL|GW_LOG_ERRNO, prog, "open %s", serverp);
+ fatal("Internal error in server");
+ }
+ if (read(linein, combuf, 2) < 2 || strcmp(combuf, "OK"))
+ {
+ gw_log (GW_LOG_FATAL, prog, "Failed to synchronize with client.");
+ fatal("Internal error in server");
+ }
+ gw_log (GW_LOG_DEBUG, prog, "Synchronized.");
+ if ((lineout = open(clientp, O_WRONLY)) < 0)
+ {
+ gw_log (GW_LOG_FATAL|GW_LOG_ERRNO, prog, "%s", clientp);
+ fatal("Internal error in server");
+ }