summaryrefslogtreecommitdiff
path: root/src/AsciiSrc.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/AsciiSrc.c')
-rw-r--r--src/AsciiSrc.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/AsciiSrc.c b/src/AsciiSrc.c
index 293f277..f069480 100644
--- a/src/AsciiSrc.c
+++ b/src/AsciiSrc.c
@@ -55,6 +55,12 @@ in this Software without prior written authorization from the X Consortium.
# include <X11/Xaw3d/AsciiText.h> /* for Widget Classes. */
#endif
+#ifdef O_CLOEXEC
+#define FOPEN_CLOEXEC "e"
+#else
+#define FOPEN_CLOEXEC ""
+#define O_CLOEXEC 0
+#endif
/****************************************************************
*
@@ -907,7 +913,7 @@ WriteToFile(_Xconst _XtString string, _Xconst _XtString name)
{
int fd;
- if ((fd = creat(name, 0666)) == -1)
+ if ((fd = open(name, O_WRONLY | O_CREAT | O_TRUNC | O_CLOEXEC, 0666)) == -1)
return(FALSE);
if (write(fd, string, sizeof(unsigned char) * strlen(string)) == -1) {
@@ -1006,7 +1012,7 @@ InitStringOrFile(AsciiSrcObject src, Boolean newString)
XtErrorMsg("NoFile", "asciiSourceCreate", "XawError",
"Creating a read only disk widget and no file specified.",
NULL, 0);
- open_mode = "r";
+ open_mode = "r" FOPEN_CLOEXEC;
break;
case XawtextAppend:
case XawtextEdit:
@@ -1014,9 +1020,9 @@ InitStringOrFile(AsciiSrcObject src, Boolean newString)
src->ascii_src.string = fileName;
(void) tmpnam(src->ascii_src.string);
src->ascii_src.is_tempfile = TRUE;
- open_mode = "w";
+ open_mode = "w" FOPEN_CLOEXEC;
} else
- open_mode = "r+";
+ open_mode = "r+" FOPEN_CLOEXEC;
break;
default:
XtErrorMsg("badMode", "asciiSourceCreate", "XawError",