Improving mod_perl Driven Site’s Performance — Part VI: Forking and Executing Subprocesses from mod_perl Page 8

執筆者
Stas Bekman
Stas Bekman
Published: Jul 20, 2010
Updated: Nov 10, 2020
1 minute read
ServerWatch のコンテンツおよび製品のおすすめは、編集上の独立性を保っています。パートナーへのリンクをクリックすると、当社が報酬を得る場合があります。 詳細を見る



Perl’s system() is not the system(3) call [C-library]. This is
how the arguments to system() get interpreted. When there is a single
argument to system(), it’ll be checked for for having shell
metacharacters first (like *,?), and if there are any–Perl
interpreter invokes a real shell program (/bin/sh -c on Unix
platforms). If you pass a list of arguments to system(), they will be
not checked for metacharacters, but split into words if required and
passed directly to the C-level execvp() system call, which is more
efficient. That’s a very nice optimization. In other words, only
if you do:

  system "sh -c 'echo *'"

will the operating system actually exec() a copy of /bin/sh to
parse your command. But even then since sh is almost certainly
already running somewhere, the system will notice that (via the disk
inode reference) and replace your virtual memory page table with one
pointing to the existing program code plus your data space, thus will
not create this overhead.

References

Stas Bekman

Stas Bekman is a ServerWatch contributor.

ServerWatch Logo

ServerWatch is a top resource on servers. Explore the latest news, reviews and guides for server administrators now.

TechnologyAdvice が所有・運営しています。 © 2026 TechnologyAdvice. 無断転載を禁じます

広告主に関する開示:このサイトに掲載されている製品の一部は、TechnologyAdvice が報酬を受け取っている企業のものです。この報酬は、製品がこのサイトのどこにどのように表示されるか(表示される順序など)に影響する場合があります。TechnologyAdvice は、市場で入手可能なすべての企業やすべての種類の製品を掲載しているわけではありません。