rem: while ((result = fcntl(fd, F_SETLKW, &lock)) < 0 || errno == EINTR)
add: while ((result = fcntl(fd, F_SETLKW, &lock)) < 0 && errno == EINTR)
context: update_autofont_map(const String &fontname, String mapline, ErrorHandler *errh){#if HAVE_KPATHSEA    if (automatic && !map_file && getodir(O_MAP, errh))	map_file = odir[O_MAP] + "/" + get_vendor() + ".map";#endif    if (map_file == "" || map_file == "-")	fputs(mapline.c_str(), stdout);    else {	// report nocreate/verbose	if (nocreate) {	    errh->message("would update %s for %s", map_file.c_str(), String(fontname).c_str());	    return 0;	} else if (verbose)	    errh->message("updating %s for %s", map_file.c_str(), String(fontname).c_str());		int fd = open(map_file.c_str(), O_RDWR | O_CREAT, 0666);	if (fd < 0)	    return errh->error("%s: %s", map_file.c_str(), strerror(errno));	FILE *f = fdopen(fd, "r+");	// NB: also change encoding logic if you change this code#if defined(F_SETLKW) && defined(HAVE_FTRUNCATE)	{	    struct flock lock;	    lock.l_type = F_WRLCK;	    lock.l_whence = SEEK_SET;	    lock.l_start = 0;	    lock.l_len = 0;	    int result;	    while ((result = fcntl(fd, F_SETLKW, &lock)) < 0 || errno == EINTR)		/* try again */;	    if (result < 0) {		result = errno;		fclose(f);		return errh->error("locking %s: %s", map_file.c_str(), strerror(result));	    }	}#endif	// read old data from map file	StringAccum sa;	while (!feof(f))	    if (char *x = sa.reserve(8192)) {		int amt = fread(x, 1, 8192, f);		sa.forward(amt);	    } else {		fclose(f);		return errh->error("Out of memory!");	    }	String text = sa.take_string();	// add comment if necessary	bool created = (!text);	if (created)	    text = "% Automatically maintained by otftotfm or other programs. Do not edit.\n\n";	if (text.back() != '\n')	    text += "\n";	// append old encodings	int fl = 0;	int nl = text.find_left('\n') + 1;	bool changed = created;	while (fl < text.length()) {	    if (fl + fontname.length() + 1 < nl		&& memcmp(text.data() + fl, fontname.data(), fontname.length()) == 0		&& text[fl + fontname.length()] == ' ') {		// found the old name		if (text.substring(fl, nl - fl) == mapline) {		    // duplicate of old name, don't change it		    fclose(f);		    if (verbose)			errh->message("%s unchanged", map_file.c_str());		    return 0;		} else {		    text = text.substring(0, fl) + text.substring(nl);		    nl = fl;		    changed = true;		}	    }	    fl = nl;	    nl = text.find_left('\n', fl) + 1;	}	// special case: empty mapline, unchanged file	if (!mapline && !changed) {	    fclose(f);	    if (verbose)		errh->message("%s unchanged", map_file.c_str());	    return 0;	}		// add our text	text += mapline;	// rewind file#ifdef HAVE_FTRUNCATE	rewind(f);	ftruncate(fd, 0);#else	fclose(f);	f = fopen(map_file.c_str(), "w");#endif	// write data	fwrite(text.data(), 1, text.length(), f);		fclose(f);	// inform about the new file if necessary	if (created)	    update_odir(O_MAP, map_file, errh);#if HAVE_KPATHSEA && !WIN32	// run 'updmap' if present	String updmap_dir = getodir(O_MAP_PARENT, errh);	String updmap_file = updmap_dir + "/updmap";	if (automatic && file_in_kpathsea_odir(O_MAP_PARENT, map_file)	    && access(updmap_file.c_str(), X_OK) >= 0) {	    // want to run 'updmap' from its directory, can't use system()	    if (verbose)		errh->message("running %s", updmap_file.c_str());	    if (pid_t child = fork()) {# if HAVE_WAITPID		int status;		while (1) {		    pid_t answer = waitpid(child, &status, 0);		    if (answer >= 0)			break;		    else if (errno != EINTR)			errh->fatal("%s during wait", strerror(errno));		}		if (!WIFEXITED(status))		    errh->warning("%s exited abnormally", updmap_file.c_str());		else if (WEXITSTATUS(status) != 0)		    errh->warning("%s exited with status %d", updmap_file.c_str(), WEXITSTATUS(status));# endif	    } else {		if (chdir(updmap_dir.c_str()) < 0)		    errh->fatal("%s: %s during chdir", updmap_dir.c_str(), strerror(errno));		if (execl("updmap", 0) < 0)		    errh->fatal("updmap: %s during exec", strerror(errno));		exit(1);	// should never get here	    }	} else if (verbose)	    errh->message("not running updmap");#endif    }    return 0;}