g***l 发帖数: 2753 | 1 sorry no Chinese input here.
The issue is:
1. A process will add new device with name as /dev/input/eventX
2. B process needs to know the new device name as /dev/input/eventX
Initially I thought A process can export a system environment variable via
setenv(), for example set INPUT_DEVICE=/dev/input/eventX, but I found this http://docstore.mik.ua/orelly/unix/upt/ch06_02.htm. It seems you cannot share the environment variables between two different processes.
"Sooner or later, almost everyone writes a shell script that gathers some
information, sets a few environment variables, and quits. The writer then
wonders why there's no trace of the "new" environment variables to be found.
The problem is simple. A UNIX process ( 38.3 ) cannot change its parent's
environment; a UNIX process gets its own copy of the parent's environment,
and any changes it makes it keeps to itself. A process can make changes and
pass them to its children, but there's no way of going in reverse."
Any good idea to solve this issue?
thanks | a9 发帖数: 21638 | 2 写到一个文件里不行吗?
process?
http://docstore.mik.ua/orelly/unix/upt/ch06_02.htm. It seems you cannot share the environment variables between two different processes.
found.
and
【在 g***l 的大作中提到】 : sorry no Chinese input here. : The issue is: : 1. A process will add new device with name as /dev/input/eventX : 2. B process needs to know the new device name as /dev/input/eventX : Initially I thought A process can export a system environment variable via : setenv(), for example set INPUT_DEVICE=/dev/input/eventX, but I found this http://docstore.mik.ua/orelly/unix/upt/ch06_02.htm. It seems you cannot share the environment variables between two different processes. : "Sooner or later, almost everyone writes a shell script that gathers some : information, sets a few environment variables, and quits. The writer then : wonders why there's no trace of the "new" environment variables to be found. : The problem is simple. A UNIX process ( 38.3 ) cannot change its parent's
| k****e 发帖数: 2758 | 3 so many many way to do IPC
http://docstore.mik.ua/orelly/unix/upt/ch06_02.htm. It seems you cannot share the environment variables between two different processes.
found.
【在 g***l 的大作中提到】 : sorry no Chinese input here. : The issue is: : 1. A process will add new device with name as /dev/input/eventX : 2. B process needs to know the new device name as /dev/input/eventX : Initially I thought A process can export a system environment variable via : setenv(), for example set INPUT_DEVICE=/dev/input/eventX, but I found this http://docstore.mik.ua/orelly/unix/upt/ch06_02.htm. It seems you cannot share the environment variables between two different processes. : "Sooner or later, almost everyone writes a shell script that gathers some : information, sets a few environment variables, and quits. The writer then : wonders why there's no trace of the "new" environment variables to be found. : The problem is simple. A UNIX process ( 38.3 ) cannot change its parent's
| S**********r 发帖数: 14 | 4 process b自己去sysfs/devfs/procfs里遍历查找出eventX.
怎么去遍历?有api或者直接system()调其他现成的程序 |
|