Re: [PATCH] make execve(NULL) re-execute current binary

From: Denys Vlasenko
Date: Tue Jun 30 2009 - 08:10:33 EST


On Tue, Jun 30, 2009 at 12:27 AM, Alan Cox<alan@xxxxxxxxxxxxxxxxxxx> wrote:
> On Tue, 30 Jun 2009 00:03:39 +0200
> Denys Vlasenko <vda.linux@xxxxxxxxxxxxxx> wrote:
>
>> Hi Al, Andrew, folks,
>>
>> This is a version 2 of re-execution patch.
>>
>> I replaced hardcoded "/proc/self/exe" with execve(NULL)
>
> So you add hacks to sys_execve, which means hacks on every system that
> doesn't need it

Yes.

> and also undefined behaviour if you use the feature when
> it isn't present.

The behavior of execve(NULL) is not undefined. It returns EFAULT.
The idea was that application will do:

/* Try traditional way */
execv("/proc/self/exe", argv);

/* Try Linux specific extension (only new kernels have it) */
execv(NULL, argv);

/* Give up */
printf("Can't re-exec myself\n");
exit(1);

which is safe on older kernels as well.

> Please implement sys_reexec() as was suggested before.

Ok.

--
vda
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/