There is a long-lived PHP process, which supports signals (SIGHUP etc.) and another PHP process needs to know the PID of the first one to send a signal.
I’d like to set an environment variable, which would be read in the second (client) process and used for my purposes, but putenv(...posix_getpid()...) doesn’t seem to make it visible to another process.
How do I make an environment variable, set in one PHP process, visible to another? If that’s impossible, what’s the preferred way (I’d like not to use files or db for this)?
What you are talking about is Inter-Process Communication (IPC). Solutions include using a socket, a named pipe, a file, redis, some message bus/queue, etc. This is a common and complex problem in software development, and one with many many robust options.
Sounds like a simple file would work fine for you and is probably the… simplest.