Bash子进程在执行eval exec时杀死父进程
我编写了以下代码来为多个文件执行python脚本。当Bash子进程在执行eval exec时杀死父进程,bash,Bash,我编写了以下代码来为多个文件执行python脚本。当script.py执行并使用循环中的第一个文件完成时,父进程存在。我找不到一个办法堵住这个出口 #!/bin/bash args= for arg in "$@"; do args="$args '$arg'" done for file in /home/andrew/Downloads/xmls/* do echo $file eval exec "python script.py $file $ar
script.py
执行并使用循环中的第一个文件完成时,父进程存在。我找不到一个办法堵住这个出口
#!/bin/bash
args=
for arg in "$@";
do
args="$args '$arg'"
done
for file in /home/andrew/Downloads/xmls/*
do
echo $file
eval exec "python script.py $file $args"
done
它不会退出。shell被
python
进程替换,因为您正在执行它
删除exec
,使python
进程作为当前shell的子进程生成
此处也不需要使用eval
,并且$args
可以替换为$@
:
python script.py "$file" "$@"
它不会退出。shell被
python
进程替换,因为您正在执行它
删除exec
,使python
进程作为当前shell的子进程生成
此处也不需要使用eval
,并且$args
可以替换为$@
:
python script.py "$file" "$@"