non-persistant storage?

Corinna Vinschen corinna-cygwin@cygwin.com
Mon Dec 16 10:22:00 GMT 2019


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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://cygwin.com/pipermail/cygwin/attachments/20191216/be7b952a/attachment.sig>


More information about the Cygwin mailing list