[CSOUND-DEV:5653] temp files
Date | 2005-01-08 07:04 |
From | "Matt J. Ingalls" |
Subject | [CSOUND-DEV:5653] temp files |
do you think it is dangerous using tmpnam() instead of tmpfil() ? on my machine at least, if i run 2 csound processes at once, they will both create temp files with the same name. -m |
Date | 2005-01-08 12:07 |
From | jpff@codemist.co.uk |
Subject | [CSOUND-DEV:5654] Re: temp files |
tmpfil is not ANSI C89. ==John ffitch |
Date | 2005-01-09 03:26 |
From | "Matt J. Ingalls" |
Subject | [CSOUND-DEV:5655] Re: temp files |
sorry i meant tmpfile() On Sat, 8 Jan 2005 jpff@codemist.co.uk wrote: > tmpfil is not ANSI C89. > ==John ffitch > > |
Date | 2005-01-26 17:23 |
From | Anthony Kozar |
Subject | [CSOUND-DEV:5754] Re: temp files |
That would seem to be a bug in your tmpnam() then. According to the Metrowerks documentation (pro 4), tmpnam() is supposed to create a unique name. Unless you are saying that both processes generate the same name before either one can open the file. I guess that would be a potential problem, but to have two processes running that closely in lock step seems unusual. Anthony On 1/8/05 2:04 AM, Matt J. Ingalls |
Date | 2005-01-26 19:31 |
From | ramsdell@mitre.org (John D. Ramsdell) |
Subject | [CSOUND-DEV:5755] Re: temp files |
The manual page on tmpnam says: BUGS Never use this function. Use mkstemp(3) instead. Please heed this warning. John Anthony Kozar |
Date | 2005-01-26 20:14 |
From | Istvan Varga |
Subject | Re: [Cs-dev] Re: [CSOUND-DEV:5754] Re: temp files |
John D. Ramsdell wrote: >The manual page on tmpnam says: > >BUGS > Never use this function. Use mkstemp(3) instead. > > > However, quoting from the mkstemp manual: "CONFORMING TO BSD 4.3, POSIX 1003.1-2001" I think it would make sense to implement a temporary file name generator function in the Csound API, so that it can be implemented on all platforms using the best method available, and system specific code would be limited to one place. ------------------------------------------------------- This SF.Net email is sponsored by: IntelliVIEW -- Interactive Reporting Tool for open source databases. Create drag-&-drop reports. Save time by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, etc. Download a FREE copy at http://www.intelliview.com/go/osdn_nl _______________________________________________ Csound-devel mailing list Csound-devel@lists.sourceforge.net |
Date | 2005-01-26 20:20 |
From | Anthony Kozar |
Subject | [Cs-dev] Re: [CSOUND-DEV:5755] Re: temp files |
I've seen a similar warning when compiling Csound with GCC. However, I cannot find this function in the MacOS 9 standard library. Which header file is mkstemp() supposed to be in? Anthony On 1/26/05 2:31 PM, John D. Ramsdell |
Date | 2005-01-26 21:16 |
From | jpff@codemist.co.uk |
Subject | [CSOUND-DEV:5756] Re: temp files |
I repeat, mktemp is not ANSI C89, and for that reason I have not changed the code. ==John ffitch |
Date | 2005-01-26 22:06 |
From | ramsdell@mitre.org (John D. Ramsdell) |
Subject | [Cs-dev] Re: [CSOUND-DEV:5756] Re: temp files |
jpff@codemist.co.uk writes: > I repeat, mktemp is not ANSI C89, and for that reason I have not > changed the code. John is, of course, right. The Lunux manual for mkstemp says it is: CONFORMING TO BSD 4.3, POSIX 1003.1-2001 John ------------------------------------------------------- This SF.Net email is sponsored by: IntelliVIEW -- Interactive Reporting Tool for open source databases. Create drag-&-drop reports. Save time by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, etc. Download a FREE copy at http://www.intelliview.com/go/osdn_nl _______________________________________________ Csound-devel mailing list Csound-devel@lists.sourceforge.net |
Date | 2005-01-26 22:11 |
From | Matt Ingalls |
Subject | Re: [Cs-dev] Re: [CSOUND-DEV:5754] Re: temp files |
but i think tmpfile() is ANSI and mkstemp is not? On Jan 26, 2005, at 12:14 PM, Istvan Varga wrote: > John D. Ramsdell wrote: > >> The manual page on tmpnam says: >> >> BUGS >> Never use this function. Use mkstemp(3) instead. >> >> > However, quoting from the mkstemp manual: > "CONFORMING TO > BSD 4.3, POSIX 1003.1-2001" > I think it would make sense to implement a temporary file > name generator function in the Csound API, so that it can > be implemented on all platforms using the best method > available, and system specific code would be limited to > one place. > > > > ------------------------------------------------------- > This SF.Net email is sponsored by: IntelliVIEW -- Interactive Reporting > Tool for open source databases. Create drag-&-drop reports. Save time > by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, etc. > Download a FREE copy at http://www.intelliview.com/go/osdn_nl > _______________________________________________ > Csound-devel mailing list > Csound-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/csound-devel > ------------------------------------------------------- This SF.Net email is sponsored by: IntelliVIEW -- Interactive Reporting Tool for open source databases. Create drag-&-drop reports. Save time by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, etc. Download a FREE copy at http://www.intelliview.com/go/osdn_nl _______________________________________________ Csound-devel mailing list Csound-devel@lists.sourceforge.net |
Date | 2005-01-26 22:24 |
From | "Matt J. Ingalls" |
Subject | [CSOUND-DEV:5757] Re: temp files |
did you see my longish post a couple hours ago on the new dev list? i didnt [and only reason i am posting here we should stop using this list] bug or not, the race condition you mention could happen - and it might be more likely to happen when we get fully reentrant and all global data removed & we will have the ability to start multiple processes -- i could see some interest in running multiple processes at once with different thread priorities or something like that... then you could have some launcher/host app/script/etc starts a bunch of processes at once.. -m On Wed, 26 Jan 2005, Anthony Kozar wrote: > That would seem to be a bug in your tmpnam() then. According to the > Metrowerks documentation (pro 4), tmpnam() is supposed to create a unique > name. > > Unless you are saying that both processes generate the same name before > either one can open the file. I guess that would be a potential problem, > but to have two processes running that closely in lock step seems unusual. > > Anthony > > On 1/8/05 2:04 AM, Matt J. Ingalls |
Date | 2005-01-26 22:38 |
From | "Matt J. Ingalls" |
Subject | [CSOUND-DEV:5758] Re: temp files |
but tmpfile() is and it is thread-safe! On Wed, 26 Jan 2005 jpff@codemist.co.uk wrote: > I repeat, mktemp is not ANSI C89, and for that reason I have not > changed the code. > ==John ffitch > > |
Date | 2005-01-26 23:46 |
From | ramsdell@mitre.org (John D. Ramsdell) |
Subject | [Cs-dev] Csound 4 is not ANSI C89 |
I noticed that csound/ccsound.c was not ANSI C89, so I tried compiling the Csound 4 source using GCC with -ansi. I found out there are many parts of Csound 4 that are not ANSI C89. The file csound/aifc.c contains multi-byte characters, but worse, csound/csound.h uses C++ style one line comments--a C99 feature. I fixed csound/ccsound.c, but did not touch anything else. John jpff@codemist.co.uk writes: > I repeat, mktemp is not ANSI C89, and for that reason I have not > changed the code. > ==John ffitch ------------------------------------------------------- This SF.Net email is sponsored by: IntelliVIEW -- Interactive Reporting Tool for open source databases. Create drag-&-drop reports. Save time by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, etc. Download a FREE copy at http://www.intelliview.com/go/osdn_nl _______________________________________________ Csound-devel mailing list Csound-devel@lists.sourceforge.net |
Date | 2005-01-26 23:52 |
From | ramsdell@mitre.org (John D. Ramsdell) |
Subject | Re: [Cs-dev] Re: [CSOUND-DEV:5754] Re: temp files |
Matt Ingalls |
Date | 2005-01-26 23:57 |
From | Matt Ingalls |
Subject | Re: [Cs-dev] Re: [CSOUND-DEV:5754] Re: temp files |
i am suggesting changing the code! On Jan 26, 2005, at 3:52 PM, John D. Ramsdell wrote: > Matt Ingalls |
Date | 2005-01-27 00:15 |
From | ramsdell@mitre.org (John D. Ramsdell) |
Subject | Re: [Cs-dev] temp files |
Matt Ingalls |
Date | 2005-01-27 06:26 |
From | jpff@codemist.co.uk |
Subject | Re: [Cs-dev] Csound 4 is not ANSI C89 |
I repeatedly remove the // comments for /* */ in all csound sources. As I have abandoned csound4 the non-ANSI bits in aiff which have anoyed me for years are no longer a problem. ==John ffitch ------------------------------------------------------- This SF.Net email is sponsored by: IntelliVIEW -- Interactive Reporting Tool for open source databases. Create drag-&-drop reports. Save time by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, etc. Download a FREE copy at http://www.intelliview.com/go/osdn_nl _______________________________________________ Csound-devel mailing list Csound-devel@lists.sourceforge.net |
Date | 2005-01-27 09:57 |
From | Istvan Varga |
Subject | Re: [Cs-dev] Csound 4 is not ANSI C89 |
John D. Ramsdell wrote: > I noticed that csound/ccsound.c was not ANSI C89, so I tried compiling > the Csound 4 source using GCC with -ansi. I found out there are many > parts of Csound 4 that are not ANSI C89. The file csound/aifc.c > contains multi-byte characters, but worse, csound/csound.h uses C++ > style one line comments--a C99 feature. I fixed csound/ccsound.c, > but did not touch anything else. Would it be possible to switch to C99, at least in Csound5 ? It has many useful features compared to C89. How many people use compilers that still do not support C99 ? ------------------------------------------------------- This SF.Net email is sponsored by: IntelliVIEW -- Interactive Reporting Tool for open source databases. Create drag-&-drop reports. Save time by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, etc. Download a FREE copy at http://www.intelliview.com/go/osdn_nl _______________________________________________ Csound-devel mailing list Csound-devel@lists.sourceforge.net |
Date | 2005-01-27 10:10 |
From | Istvan Varga |
Subject | Re: [Cs-dev] Re: [CSOUND-DEV:5754] Re: temp files |
Matt Ingalls wrote: > but i think tmpfile() is ANSI and mkstemp is not? Correct. tmpfile() does have some minor disadvantages, though: 1. You cannot control when the files are deleted. It always happens when the program terminates, however it would be preferable to delete tmp files at the end of a Csound instance (otherwise, in a re-entrant version tmp files would keep accumulating until you actually quit). On the other hand, sometimes it would be useful to keep the files. 2. It returns a FILE* handle instead of a file name (that is needed for the improved reliability compared to tmpnam()), and there is no possibility of closing and then re-opening a file. This is a problem, because CSD files are first converted to temporary orc and sco files, which are written, closed, and then the name is passed to the orc/sco parser. This system would need to be changed if tmpfile() is used. ------------------------------------------------------- This SF.Net email is sponsored by: IntelliVIEW -- Interactive Reporting Tool for open source databases. Create drag-&-drop reports. Save time by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, etc. Download a FREE copy at http://www.intelliview.com/go/osdn_nl _______________________________________________ Csound-devel mailing list Csound-devel@lists.sourceforge.net |
Date | 2005-01-27 20:22 |
From | Matt Ingalls |
Subject | Re: [Cs-dev] temp files |
here is the main problem we are experiencing: + tmpnam() always creates the same temp file names temp000000, temp000001, temp000002, etc.. for every csound process. + user runs csound and kills process [a common thing on commandline with an "endless" score (f0 99999)] or crashes, temp files are not deleted. + another user tries to run csound, and when it tries to create temp00000 file it returns an error because it doesnt have proper privileges to write over other user's temp files. i think its worth trying to replace with tmpfile() even if it takes a bit of work. i wouldnt mind seeing all those "using score file temp0000001.sco" output messages go away anyway.... OR is there an ANSII way to get the name/id/etc of the current user? it would then be possible to create a directory for each user in /tmp and then do something like: char username[256]; getusername(username); sprintf(sconame, "/tmp/%s/%s", username, tmpnam(NULL)); strcat(sconame, ".sco"); scof = fopen(sconame, "w"); well what do you guys do on other platforms? thanks for your help, m On Jan 26, 2005, at 4:15 PM, John D. Ramsdell wrote: > Matt Ingalls |
Date | 2005-01-28 01:04 |
From | ramsdell@mitre.org (John D. Ramsdell) |
Subject | Re: [Cs-dev] Re: [CSOUND-DEV:5754] Re: temp files |
Istvan Varga |
Date | 2005-01-28 06:25 |
From | jpff@codemist.co.uk |
Subject | Re: [Cs-dev] temp files |
A random number would be better than always starting from 0. ==John ffitch ------------------------------------------------------- This SF.Net email is sponsored by: IntelliVIEW -- Interactive Reporting Tool for open source databases. Create drag-&-drop reports. Save time by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, etc. Download a FREE copy at http://www.intelliview.com/go/osdn_nl _______________________________________________ Csound-devel mailing list Csound-devel@lists.sourceforge.net |
Date | 2005-01-28 16:35 |
From | Charles Baker |
Subject | Re: [Cs-dev] temp files |
The unix-y thing to do would be to create a .csound directory in the users home dir (i.e. "~" ) and keep all tmp files there. As far as win, one could perhaps create a similar dir, hidden or not? Cleaning said directory on program quit could be an option one could toggle? cb On Jan 27, 2005, at 3:22 PM, Matt Ingalls wrote: > here is the main problem we are experiencing: > > + tmpnam() always creates the same temp file names > temp000000, temp000001, temp000002, etc.. > for every csound process. > > + user runs csound and kills process [a common thing on commandline > with an "endless" score (f0 99999)] or crashes, temp files > are not deleted. > > + another user tries to run csound, and when it tries to create > temp00000 file it returns an error because it doesnt have proper > privileges to write over other user's temp files. > > > i think its worth trying to replace with tmpfile() even if it takes a > bit of work. > i wouldnt mind seeing all those "using score file temp0000001.sco" > output > messages go away anyway.... > > OR > > is there an ANSII way to get the name/id/etc of the current user? it > would > then be possible to create a directory for each user in /tmp and then > do something like: > > char username[256]; > getusername(username); > sprintf(sconame, "/tmp/%s/%s", username, tmpnam(NULL)); > strcat(sconame, ".sco"); > scof = fopen(sconame, "w"); > > well what do you guys do on other platforms? > > > thanks for your help, > m > > On Jan 26, 2005, at 4:15 PM, John D. Ramsdell wrote: > >> Matt Ingalls |
Date | 2005-01-28 17:34 |
From | ramsdell@mitre.org (John D. Ramsdell) |
Subject | Re: [Cs-dev] temp files |
Matt Ingalls |
Date | 2005-01-28 19:54 |
From | Anthony Kozar |
Subject | Re: [Cs-dev] temp files |
Would it? You would end up with the same random number unless you seed the generator. But if you start two instances of csound back to back in a shell script for example, I think that you will be likely to get the same value from time() to seed with. Anthony On 1/28/05 1:25 AM, jpff@codemist.co.uk |
Date | 2005-01-28 20:01 |
From | Anthony Kozar |
Subject | Re: [Cs-dev] temp files |
On 1/27/05 3:22 PM, Matt Ingalls |
Date | 2005-01-29 16:02 |
From | Istvan Varga |
Subject | Re: [Cs-dev] temp files |
Anthony Kozar wrote: > Would it? You would end up with the same random number unless you seed the > generator. But if you start two instances of csound back to back in a shell > script for example, I think that you will be likely to get the same value > from time() to seed with. With the 'unsigned long timers_random_seed(void)' function (already in CVS), you can get a 32 bit unsigned seed value from timers that have the following resolution: * Linux/GCC/i386: CPU cycles (better than nanosecond) * Win32: the resolution of QueryPerformanceCounter(), should be better than microseconds * unix-like systems (including MacOS X?): microseconds (gettimeofday()) * others: 1 second (time()) This function (and other time related ones) is in csound.c (may need to change some #ifdefs, as I cannot test all systems). Of course, this still does not guarantee 100% safety for temporary file names. We can either use tmpfile(), or implement system dependent temporary file code (with mkstemp() or whatever is available) and add it to the API so that the #ifdefs will at least only appear in one place. tmpfile() has the advantage that it is ANSI, and should be reliable, but there is no way to control when the files are deleted, and it is not compatible with the current way of using temporary files in Csound. ------------------------------------------------------- This SF.Net email is sponsored by: IntelliVIEW -- Interactive Reporting Tool for open source databases. Create drag-&-drop reports. Save time by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, etc. Download a FREE copy at http://www.intelliview.com/go/osdn_nl _______________________________________________ Csound-devel mailing list Csound-devel@lists.sourceforge.net |
Date | 2005-01-30 11:09 |
From | Richard Dobson |
Subject | Re: [Cs-dev] Csound 4 is not ANSI C89 |
Viusual C++ v6 does not support it, and I have now checked the free download of Visual C++ 7, and that does not support it either (no stdint.h anywhere, nor are the types defined anywhere else). I have yet to try the beta of Visual C++ .NET 2005 (demands more space than my spare machine can supply), but even if that does support C99 (and assumning it is not modified or "extended" in some way), many developers are likely to stick to v7, or even v6 for some time yet. Indeed, having found that even the V7 optimiser still generates astonishingly pathological instant-crash code for one particular program of mine, while the Intel compiler generates correct/efficient/compact code, I am currently rather more likely to upgrade to the Intel compiler than VC vX; and that does not support C99 either as far as I can see! So I think we will want to stick to ANSI for the forseeable future. At the very least, given the new dependence on plugins, we would want to be sure C99 modules can link to C89 ones, and the introduction of new types into c99 would seem to preclude that, except where the C99 modules are ANSI compliant anyway. Richard Dobson Istvan Varga wrote: > John D. Ramsdell wrote: > >> I noticed that csound/ccsound.c was not ANSI C89, so I tried compiling >> the Csound 4 source using GCC with -ansi. I found out there are many >> parts of Csound 4 that are not ANSI C89. The file csound/aifc.c >> contains multi-byte characters, but worse, csound/csound.h uses C++ >> style one line comments--a C99 feature. I fixed csound/ccsound.c, >> but did not touch anything else. > > > Would it be possible to switch to C99, at least in Csound5 ? It has > many useful features compared to C89. How many people use compilers > that still do not support C99 ? > > > > ------------------------------------------------------- > This SF.Net email is sponsored by: IntelliVIEW -- Interactive Reporting > Tool for open source databases. Create drag-&-drop reports. Save time > by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, etc. > Download a FREE copy at http://www.intelliview.com/go/osdn_nl > _______________________________________________ > Csound-devel mailing list > Csound-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/csound-devel > > ------------------------------------------------------- This SF.Net email is sponsored by: IntelliVIEW -- Interactive Reporting Tool for open source databases. Create drag-&-drop reports. Save time by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, etc. Download a FREE copy at http://www.intelliview.com/go/osdn_nl _______________________________________________ Csound-devel mailing list Csound-devel@lists.sourceforge.net |