Question on using /tmp
From: Shi Jin (jinzishuai_at_hotmail.com)
Date: 06/20/05
- Previous message: Lawrence DčOliveiro: "Re: Books on Linux programming"
- Next in thread: Floyd L. Davidson: "Re: Question on using /tmp"
- Reply: Floyd L. Davidson: "Re: Question on using /tmp"
- Reply: Carlos Moreno: "Re: Question on using /tmp"
- Reply: Moritz Franosch: "Re: Question on using /tmp"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sun, 19 Jun 2005 23:39:18 -0400
Hi there,
In my C code, I need to make a system call to a command to generate a
temporary file and my code is going to read something out of it.
I cannot use the pipes to redirect the output to stdout since it varies
from machine to machine. Only when I call the command in the form
tsm -Loutput.file
The command "tsm" will give me a well formated file output.file.
I want to make output.file a temporary file so that I can use the function
tmpnam or tmpfile.
I guess using tmpfile is better in the sense it generates a unique
filename in the same time creates the file. But I have to use tmpnam since
I need to create the file in another way. Now my code looks like
filename=tmpnam(tmpname);
system(command);
fp=fopen(filename,"r");
When I compile it, I get the following warnings:
warning: the use of `tmpnam' is dangerous, better use `mkstemp'
For the same reason above, I cannot use mkstemp either. I could use mktemp
which makes to difference to me compared to tmpnam.
But still, as the warning said, there is some danger in using tmpnam
although it seldom happens.
I wonder if there is a perfect solution to this.
Thank you very much
Shi
- Previous message: Lawrence DčOliveiro: "Re: Books on Linux programming"
- Next in thread: Floyd L. Davidson: "Re: Question on using /tmp"
- Reply: Floyd L. Davidson: "Re: Question on using /tmp"
- Reply: Carlos Moreno: "Re: Question on using /tmp"
- Reply: Moritz Franosch: "Re: Question on using /tmp"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|