This is the mail archive of the
systemtap@sourceware.org
mailing list for the systemtap project.
RE: [patch] Close fds before execute a cmd
- From: "Stone, Joshua I" <joshua dot i dot stone at intel dot com>
- To: "Lai Jiangshan" <laijs at cn dot fujitsu dot com>, <systemtap at sourceware dot org>
- Date: Mon, 8 Oct 2007 22:36:54 -0700
- Subject: RE: [patch] Close fds before execute a cmd
- References: <470B0D2A.4070401@cn.fujitsu.com>
Lai Jiangshan wrote:
> I traced this bug and at the last I found the reason: stapio did
not
> close some file descriptors before using execl() to run a cmd. The
> processes of this cmd may read or write on the fds inherited from
> stapio. Especially the fd of control_channel, if one of processes of
> this cmd reads and writes on this fd, it communicates with
> stap_XXXXXX.ko, and lots of BUGs occurred. (Does stap_XXXXXX.ko
> support communicating with two or more processes at the same time?)
It would be strange for an app to do anything on an already open fd, but
not unheard of, I suppose.
Rather than brute-force closing all fd > 2, a better way might be to set
FD_CLOEXEC in the appropriate places.
Josh