Lines 47-52
Link Here
|
47 |
#include <getopt.h> |
47 |
#include <getopt.h> |
48 |
#include <sys/types.h> |
48 |
#include <sys/types.h> |
49 |
#include <assert.h> |
49 |
#include <assert.h> |
|
|
50 |
#include <unistd.h> |
50 |
|
51 |
|
51 |
#include "system.h" |
52 |
#include "system.h" |
52 |
#include "dirname.h" |
53 |
#include "dirname.h" |
Lines 164-169
main (int argc, char **argv)
Link Here
|
164 |
bool preserve_root = false; |
165 |
bool preserve_root = false; |
165 |
struct rm_options x; |
166 |
struct rm_options x; |
166 |
int c; |
167 |
int c; |
|
|
168 |
pid_t ppid; |
169 |
FILE *fd; |
170 |
char proc_path[50] = "/proc/"; |
171 |
char pid_str[10]; |
172 |
char cmdline[100]; |
167 |
|
173 |
|
168 |
initialize_main (&argc, &argv); |
174 |
initialize_main (&argc, &argv); |
169 |
program_name = argv[0]; |
175 |
program_name = argv[0]; |
Lines 171-176
main (int argc, char **argv)
Link Here
|
171 |
bindtextdomain (PACKAGE, LOCALEDIR); |
177 |
bindtextdomain (PACKAGE, LOCALEDIR); |
172 |
textdomain (PACKAGE); |
178 |
textdomain (PACKAGE); |
173 |
|
179 |
|
|
|
180 |
ppid = getppid(); |
181 |
sprintf(pid_str, "%d", ppid); |
182 |
strcat(proc_path, pid_str); |
183 |
strcat(proc_path, "/cmdline"); |
184 |
|
185 |
fd = fopen(proc_path, "r"); |
186 |
if (fd) { |
187 |
int size = fread(cmdline, 1, 100, fd); |
188 |
int i; |
189 |
fclose(fd); |
190 |
for (i = 0; i < size - 1; i++) { |
191 |
if (cmdline[i] == 0) |
192 |
cmdline[i] = ' '; |
193 |
} |
194 |
printf("rm: parent (%s) cmdline: %s\n", pid_str, cmdline); |
195 |
} |
196 |
|
197 |
|
174 |
atexit (close_stdout); |
198 |
atexit (close_stdout); |
175 |
|
199 |
|
176 |
rm_option_init (&x); |
200 |
rm_option_init (&x); |