YottaDB / YDB

Mirrored from https://gitlab.com/YottaDB/DB/YDB
Other
76 stars 37 forks source link

Do not assert fail in case tcsetattr() call fails and a white-box case indicates terminal is killed #279

Closed nars1 closed 6 years ago

nars1 commented 6 years ago

This fixes an occasional v63003/gtm8787 subtest failure due to an assert failure at line 457 below.

iott_use.c
  454  Tcsetattr(tt_ptr->fildes, TCSANOW, &t, status, save_errno);
  455  if (0 != status)
  456  {
  457          assert(FALSE);
  458          rts_error_csa(CSA_ARG(NULL) VARLSTCNT(4) ERR_TCSETATTR, 1, tt_ptr->fildes, save_errno);
  459  }

In the gtm8787 subtest, the terminal is killed so the error from Tcsetattr() (save_errno = 5/EIO) is not unexpected. To work around the assert failure, check for a specific white-box case (the newly introduced WBTEST_KILL_TERMINAL case) and if so skip the assert.

While modifying iott_use.c, noticed a ISSUE_NOPRINCIO_IF_NEEDED_TT usage in case tcgetattr() call on the terminal fd fails. I don't see the need for this call to issue NOPRINCIO error. It is better for the NOPRINCIO error to be issued if a write() to the terminal fails (taken care of in iott_write.c and iott_flush.c). So removed this usage in iott_use.c. In this case, a TCGETATTR error would be issued and that should be good enough. If ever an attempt is made to display this error message to the terminal then a NOPRINCIO error would be issued which seems more appropriate to me.