4

I'm creating a fault injection framework, and would like to do something like:

volatile bool doFaultWriteError;

In my code, I can then check the global variable to decide whether to do the fault.

In BSD, I hear you can teach sysctl to set variable in user space processes. Is this possible in Linux? How do I do it?

My current plan is to have a SIGHUP handler that read a "fault configuration" file and then sets globals as appropriate. But if there's already something in Linux that can do this, that would be simpler.

Nikhil
  • 2,298
  • 13
  • 14
Martin C. Martin
  • 3,565
  • 3
  • 29
  • 36

2 Answers2

5

You can use mmap to share a page via a file handler (shm_open) then communicate between two applications.

auselen
  • 27,577
  • 7
  • 73
  • 114
-1

You cannot change the environment of another process, and I would be surprised if you could do that in any UNIX system.

There are some hacks described in this other question: Is there a way to change another process's environment variables? but they are just ugly hacks :)

Community
  • 1
  • 1
Martina Ferrari
  • 382
  • 2
  • 7