Commits

Yuya Nishihara committed 38bc93a

hgclient: close stdin on kill request so that chg can exit immediately

Also avoids unwanted response of the read request, which may be recognized
as new request by commandserver.

  • Participants
  • Parent commits 4d7b7c2

Comments (0)

Files changed (1)

 {
     context_t *ctx = &hgc->ctx;
     size_t r = fread(ctx->data, sizeof(ctx->data[0]), ctx->datasize, stdin);
+    if (hgc->state == STATE_KILLING) return;
     ctx->datasize = r;
     writeblock(hgc);
 }
 {
     context_t *ctx = &hgc->ctx;
     if (!fgets(ctx->data, ctx->datasize, stdin)) ctx->data[0] = '\0';
+    if (hgc->state == STATE_KILLING) return;
     ctx->datasize = strlen(ctx->data);
     writeblock(hgc);
 }
     if (kill(hgc->serverpid, sig) < 0)
         abortmsg("cannot kill %d (errno = %d)", hgc->serverpid, errno);
     hgc->state = STATE_KILLING;
+    fclose(stdin);  // so that blocking read can be ended
 }
 
 /*!