Answer the question
In order to leave comments, you need to log in
Linux: binary name spoofing - what are the unpredictable consequences?
There is a complex chain of program calls (some processes start several other processes). There was a need to solve compatibility problems to perform some preliminary steps before running the progX
binary executable (which is not called by me, but by other processes).
mv progX progX_orig
Create your own progX:
#!/bin/sh
# некоторые действия:
# обработка входных параметров,
# установка дополнительных переменных окружения,
# и т.д. ...
path_to_dir/progX_orig $*
Answer the question
In order to leave comments, you need to log in
1. This is an absolutely normal approach.
2. If the program call is the last action of the script, then it is better not to do a subprocess, but to replace the current process with a program, which saves some memory and preserves the parent-child relationship for signals (i.e. after the script is processed, the parent program will receive exactly the same state of the child process, as well as before replacing the program with a script):
#!/bin/sh
# некоторые действия:
# обработка входных параметров,
# установка дополнительных переменных окружения,
# и т.д. ...
exec path_to_dir/progX_orig $*
exec path_to_dir/progX_orig "[email protected]"
Depends on what the progX binary is and who else is using it.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question