[PATCH] dropbear-051: uClinux vfork
Farrell Aultman
fja0568 at gmail.com
Wed Oct 22 22:41:04 WST 2008
Again, it would be better to do something like the following in includes.h:
+#ifdef __uClinux__
+#define exit(x) _exit(x)
+#endif
On Tue, Oct 21, 2008 at 1:01 AM, Mike Frysinger <vapier at gentoo.org> wrote:
> On Saturday 20 September 2008, Jamie Lokier wrote:
> > Farrell Aultman wrote:
> > > Between dropbear-047 and dropbear-051 changes were made that
> > > accounted for the fact that uClinux needs to use vfork instead of
> > > fork. However, fork was not replaced with vfork in all places. I
> > > moved the conditional preproccessor check for uClinux into the
> > > includes.h file, so that fork is always replaced with vfork in all
> > > of the dropbear code when compiling for uClinux. A side effect is
> > > that the code is cleaner since you just call fork without wrapping
> > > it every time with a conditional preprocessor check.
> >
> > Have you checked that it's safe to call vfork in all those places?
> >
> > vfork is not always a safe replacement for fork, even on uClinux where
> > fork doesn't work.
>
> it istn safe. the exit() calls need to be updated too. the patch i wrote
> is
> here (i could have sworn i posted it already):
> --- dropbear-0.51/scp.c
> +++ dropbear-0.51/scp.c
> @@ -130,13 +130,22 @@
> fprintf(stderr, " %s", a->list[i]);
> fprintf(stderr, "\n");
> }
> - if ((pid = fork()) == -1)
> +#ifdef __uClinux__
> + pid = vfork();
> +#else
> + pid = fork();
> +#endif /* __uClinux__ */
> + if (pid == -1)
> fatal("do_local_cmd: fork: %s", strerror(errno));
>
> if (pid == 0) {
> execvp(a->list[0], a->list);
> perror(a->list[0]);
> +#ifdef __uClinux__
> + _exit(1);
> +#else
> exit(1);
> +#endif /* __uClinux__ */
> }
>
> do_cmd_pid = pid;
> @@ -225,7 +234,11 @@
>
> execvp(ssh_program, args.list);
> perror(ssh_program);
> +#ifndef __uClinux__
> exit(1);
> +#else
> + _exit(1);
> +#endif /* __uClinux__ */
> } else if (do_cmd_pid == -1) {
> fatal("fork: %s", strerror(errno));
> }
> -mike
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ucc.gu.uwa.edu.au/pipermail/dropbear/attachments/20081022/b3954dca/attachment-0001.htm
More information about the Dropbear
mailing list