+Index: lyx-devel/src/support/tempname.C
+===================================================================
+RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/support/tempname.C,v
+retrieving revision 1.4
+diff -u -r1.4 tempname.C
+--- lyx-devel/src/support/tempname.C 2000/11/15 03:22:08 1.4
++++ lyx-devel/src/support/tempname.C 2001/01/01 01:09:10
+@@ -12,6 +12,17 @@
+
+ extern string system_tempdir;
+
++#ifdef __EMX__
++ // EMX mkstemp() behaviour may be problematic, however,
++ // as noted by Lgb in the comment to CreateTmpDir(),
++ // there is no point for using mkstemp() here.
++#undef HAVE_MKSTEMP
++#include <sys/types.h>
++#include <sys/stat.h>
++#define INCL_DOSFILEMGR
++#include <os2.h>
++#endif
++
+ static inline
+ int make_tempfile(char * templ)
+ {
+@@ -19,9 +30,14 @@
+ return ::mkstemp(templ);
+ #else
+ #ifdef HAVE_MKTEMP
++#ifdef __EMX__
++ ULONG cur = 0;
++ LONG req = 1;
++ DosSetRelMaxFH(&req, &cur); // No need to check error code.
++#endif
+ // This probably just barely works...
+ ::mktemp(templ);
+- return ::open(templ, O_CREAT | O_EXCL, S_IRUSR | S_IWUSR);
++ return ::open(templ, O_RDWR | O_CREAT | O_EXCL, S_IRUSR | S_IWUSR);
+ #else
+ #warning FIX FIX FIX
+ #endif