This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: non-persistant storage?


Hi Ulli,

On Dec 12 13:00, Ulli Horlacher wrote:
> I need to store some data (a few kB) non-persistant.
> On a real UNIX I would use /var/run, because after a shutdown all its
> content is lost.
> But on cygwin /var/run is stored on disk.
> 
> I cannot use an environment variable, because different processes need to
> read/write the data.
> 
> /proc is non-persistant (in respect to a reboot), but It is not a generic
> storage place.
> 
> What can I use with cygwin instead?
> 
> Installing third party software is not an option, it must work with a
> standard Windows (and cygwin).

Cygwin is just a user space DLL, it's not an OS.  Creating RAM disk-like
storage is the job of the OS or an OS driver.  Unfortunately, there's no
onboard RAM disk driver in Windows, just zillions of third-party solutions.

I see two options:

- Use XSI shared memory, as outlined in this thread already, or

- If you have the executables under source control, you can use
  an O_TMPFILE on /dev/shm, and fork the worker process from there,
  i.e.

    fd = open ("/dev/shm", O_TMPFILE | O_RDWR, S_IRUSR | S_IWUSR);
    if (fd >= 0)
      {
	write (fd, your_key, strlen (your_key));
	switch (fork ())
	  {
	  case 0: /* child */
	    /* Use fd as you see fit */
	    break;
	  case -1: /* error */
	  default: /* parent */
	    close (fd);
	    wait (&status);
	    break;
	  }
      }


Corinna

-- 
Corinna Vinschen
Cygwin Maintainer

Attachment: signature.asc
Description: PGP signature


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]