Sep 16, 2006


I'm starting the Mono POSIX shared memory wrapping, decided to begin dllimporting shm_open, however doesn't seems to be easy at all, my current effort is:

using System;
using System.Runtime.InteropServices;

namespace Mono.Posix {
public class SharedMemory
public SharedMemory ()
{ }

[DllImport ("librt", EntryPoint="shm_open", CharSet=CharSet.Ansi,
public static extern IntPtr Open (
[MarshalAs (UnmanagedType.LPStr)] string name,
int oflag,
int mode_t);

public static void Main (string []args)
//O_RDONLY = 00
//O_WRONLY = 01
//O_RDWR = 02
SharedMemory m = new SharedMemory ();
SharedMemory.Open ("test", 0, 777);

After compiling and running, I get:

SharedMemory.cs(22,17): warning CS0219: The variable `m' is assigned but its value is never used
Compilation succeeded - 1 warning(s)

Unhandled Exception: System.ExecutionEngineException: SIGILL
at [0x00000] unknown method
at (wrapper managed-to-native) Mono.Posix.SharedMemory:Open (string,int,int)
at Mono.Posix.SharedMemory.Main (System.String[] args) [0x00000]

Ignore the warning and notice the SIGILL related exception, may it be something about current marshaling? Will again, but later, I need to rest, tomorrow will wake up earlier.