Questions tagged [mkstemp]

The mkstemp() function generates a unique temporary filename. Part of glibc.

The mkstemp() function generates a unique temporary filename from template, creates and opens the file, and returns an open file descriptor for the file.

more info at the man page

30 questions
2
votes
1 answer

Is there a way to automatically close a Python temporary file returned by mkstemp()

Normally I process files in Python using a with statement, as in this chunk for downloading a resource via HTTP: with (open(filename), "wb"): for chunk in request.iter_content(chunk_size=1024): if chunk: file.write(chunk) …
Ray Toal
  • 86,166
  • 18
  • 182
  • 232
1
vote
1 answer

compilation in temporary directory/file with gcc in C program

I recently discovered the mkstemp() function (see this link) but it does not fully meet my need which would be to compile temporary .o files (with gcc -c script.c for example) and can only be accessed by the PID of the current program (and destroyed…
John S
  • 231
  • 3
  • 11
1
vote
2 answers

mkstemp() implementation for Windows to write temporary files

I want to create temporary files in given temporary directory path in Windows through C++. mktemp() does the required job, but it only creates 26 unique files. mkstemp() is working fine in Linux but it is not there in Windows. So please help me to…
raj
  • 11
  • 2
1
vote
1 answer

What causes mkstemp to fail when running many simultaneous valgrind processes?

I'm doing testing of some software with valgrind. Ideally, I would like to have 20 or more instances of valgrind open at once. However, if I run more than 16 instances in parallel, I start getting messages like: ==30533== VG_(mkstemp): failed to…
John Doucette
  • 4,370
  • 5
  • 37
  • 61
0
votes
0 answers

tempfile.mkstemp return a path which is not usable for the built-in function "keras.models.save_model"

I'm trying to run the code from github. When I try to run the following code, I get the error tensorflow.python.framework.errors_impl.FailedPreconditionError: /var/folders/fh/0rzmw3r97kl4gft689jt2mhw0000gn/T/tmp-kerasmodelyv4lipk1 is not a…
0
votes
1 answer

Specifying file name with mkstemp, file not found

I need to be able to create a temporary file with a specified file name and write data to it, then zip said file with filename up along with other files: fd, path = tempfile.mkstemp(".bin", "filename", "~/path/to/working/directory/") try: with…
gravytrain
  • 73
  • 5
0
votes
1 answer

Pycharm - Couldnt connect to console process

I can't connect to the console process when I press Python console in Tools. The interpeter tries to "import mkdtemp, mkstemp" but cant import mkdtemp I have tried to check if there is something wrong with the project's settings but couldn't find…
Idan C.
  • 31
  • 6
0
votes
1 answer

EiffelStudio compile error: The use of `tempnam' is dangerous, better use `mkstemp'

I'm using eiffelstudio-bin 17.05.100416-1 installed via AUR in Arch. When I try to run the default hello world project, i have this error in the Error List tab: C Compiler Error: The use of `tempnam' is dangerous, better use `mkstemp' …
rivamarco
  • 719
  • 8
  • 23
0
votes
1 answer

Linux - How does mkstemp64 create a hidden file, and how can I see it in the file system

Background: On CentOS 7 x86_64. I am using applydeltarpm, and was running out of disk space when creating the new RPM from the delta. I watched the / disk space usage increase during the apply process to 100%, but could not find the working/temp…
Russell E Glaue
  • 1,602
  • 13
  • 9
0
votes
1 answer

mpiexec throws error "mkstemp failed No such file or directory"

I have cross compiled MPICH for Android and configured it. It works fine when I spawn a single process as follows $./mpiexec -n 1 -launcher=fork ./mpi_hello_world Hello world from processor zero, rank 0 out of 1…
Hemant Tiwari
  • 145
  • 1
  • 1
  • 9
0
votes
2 answers

Why can I not create a temporary file using a dynamically allocated string?

I am trying to create a directory with log entries with mkstemp. But, to my understanding I mustn't pass a string constant to mkstemp. I allocate memory for the string and use snprintf to format the output which I thought was going to work but…
Linus
  • 1,516
  • 17
  • 35
0
votes
1 answer

mkstemp implicit declaration of function

I have a problem with the function mkstemp(). GCC compiler on cygwin generates a warning: implicit declaration of function ‘mkstemp‘ GCC flags: -std=c99 -Wall Includes: #include #include
Heniek
  • 563
  • 2
  • 8
  • 17
0
votes
1 answer

File cannot be found when i use #Fabric put# in multi-threading to copy a temp file created by tempfile.mkstemp to a remote file

Python Version: 2.6.4 Fabric Version:1.9.0 I have an automation testing framework to execute cases in parallel by using threading.Thread(3 threads in my case). Each thread worker uses fabric put(we do some wrapper on this function though) to copy a…
3quanfeng
  • 39
  • 1
  • 9
-2
votes
1 answer

File creation doesn't always succeeded

I need to created 1000 temp files in /tmp path. Below is my approach using mkstemp (safe from race conditon), but the file creation is limited to 500 only, the rest failed. std::string open_temp(std::string path, std::ofstream& f) { path +=…
rosti
  • 1
  • 4
-2
votes
2 answers

Python mkstemp suffix

I have the following piece of code that handles the image upload for me in a Django Project that I work on: def upload_handler(source): fd, filepath = tempfile.mkstemp(prefix=source.name, dir=MEDIA_ROOT) with open(filepath, 'wb') as dest: …
MariusNV
  • 391
  • 1
  • 3
  • 7
1
2