Exec
exec 函式的第零個參數
以下是標準
exec*
函式:int execl(const char *path, const char *arg, ...); int execlp(const char *file, const char *arg, ...); int execle(const char *path, const char *arg, ..., char * const envp[]); int execv(const char *path, char *const argv[]); int execvp(const char *file, char *const argv[]); int execvpe(const char *file, char *const argv[], char *const envp[]);
將要執行的程序名稱作為參數數組的第一個成員傳遞是 Unix 慣例。
在什麼樣的實際情況下(如果有),偏離約定而不使路徑/文件與****arg/argv相同是有意義的**$$ 0 $$**?
出於另一個原因,差異已被用來改變過程的出現方式
ps
。其中一些已經被作業系統的改變所消除。考慮到這一點,這裡有一些指向範例的連結:
特別是,@sami-kuhmonen關於使符號連結“看起來”像真實文件的評論。
- 隱藏.c
/*---------------------------------------------------------------------------+ | Copyright (c) 1992 Oracle Corporation Belmont, California, USA | | All rights reserved | +---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------+ | FILENAME | | hide.c | | DESCRIPTION | | Hides arguments for programs on UNIX systems. | | Can be used as a program prefix: hide program arguments | | or as a symbolic link. If this program is not invoked as hide, it | | will hide its arguments and invoke the program name.hide | | The best way to use this is to rename your critical programs to | | program.hide, and create a symbolic link program to hide. | | mv sqlplus sqlplus.hide; ln -s hide sqlplus | | Thus when sqlplus is invoked, its arguments will be hidden | | NOTES | | This program works by padding 3000 '/' chars in argv[0]. This fools | | all known ps's. This will reduce the argument capacity of your | | program by 3000 chars. A good enhancement would be to reduce the | | padding if needed so that no arguments are lost - would require a | | method of determining the max argument size on the system. Some | | system's provide the E2BIG error on exec. | | There is some performace penalty for using this program, but it is | | minimal because this program is so small - the biggest cost is the | | extra exec required to get this program started. | | HISTORY | | 09/15/92 R Brodersen Created, based on D Beusee's hideargs() | | 09/17/92 D Beusee Fixed to compile on any system | +---------------------------------------------------------------------------*/