@@ -1265,6 +1265,18 @@ bool running_in_debugger(){
12651265}
12661266
12671267#if defined(__APPLE__) || defined(__GLIBC__)
1268+ static void
1269+ perror_sig_safe (const char *s)
1270+ {
1271+ char buf[128 ];
1272+ char *start = buf;
1273+ const char *const end = buf + sizeof buf;
1274+ strappend (&start, end, s);
1275+ strappend (&start, end, " : " );
1276+ append_number (&start, end, errno);
1277+ strappend (&start, end, " \n " );
1278+ write_all (STDERR_FILENO, start - buf, buf);
1279+ }
12681280// / dumps output of fd (from start_off offset) to stderr
12691281// / and keep the pointer at the end of the file
12701282// / @retval size of the file pointed by fd (current pos)
@@ -1275,7 +1287,11 @@ st_glibc_flush_output(int fd, off_t start_off)
12751287 return 0 ;
12761288 }
12771289
1278- lseek (fd, start_off, SEEK_SET);
1290+ const off_t off = lseek (fd, start_off, SEEK_SET);
1291+ if (off == -1 ) {
1292+ perror_sig_safe (" lseek" );
1293+ }
1294+
12791295 char buf[STR_LEN];
12801296 ssize_t rbytes = 0 ;
12811297 while ((rbytes = read (fd, buf, sizeof buf)) > 0 ) {
0 commit comments