include process id in expect buffer name

This commit is contained in:
Folkert 2022-10-12 21:06:44 +02:00
parent 19ea3489cb
commit 2b60cb1dcd
No known key found for this signature in database
GPG Key ID: 1F17F6FFD112B97C
2 changed files with 10 additions and 5 deletions

View File

@ -921,9 +921,9 @@ fn roc_dev_native(
let mut signals = Signals::new(&[SIGCHLD, SIGUSR1]).unwrap();
// let shm_name = format!("/roc_expect_buffer_{}", std::process::id());
let shm_name = "/roc_expect_buffer";
let memory = ExpectMemory::create_or_reuse_mmap(shm_name);
// let shm_name =
let shm_name = format!("/roc_expect_buffer_{}", std::process::id());
let memory = ExpectMemory::create_or_reuse_mmap(&shm_name);
let layout_interner = layout_interner.into_global();

View File

@ -30,8 +30,13 @@ extern fn roc_getppid() c_int;
pub fn readSharedBufferEnv() callconv(.C) void {
if (builtin.os.tag == .macos or builtin.os.tag == .linux) {
const name = "/roc_expect_buffer"; // IMPORTANT: shared memory object names must begin with / and contain no other slashes!
const shared_fd = roc_shm_open(@ptrCast(*const i8, name), O_RDWR | O_CREAT, 0o666);
// const name = "/roc_expect_buffer";
// IMPORTANT: shared memory object names must begin with / and contain no other slashes!
var name: [100]u8 = undefined;
_ = std.fmt.bufPrint(name[0..100], "/roc_expect_buffer_{}\x00", .{roc_getppid()}) catch unreachable;
const shared_fd = roc_shm_open(@ptrCast(*const i8, &name), O_RDWR | O_CREAT, 0o666);
const length = 4096;
const shared_ptr = roc_mmap(