On Thu, 2009-01-22 at 11:09 +0800, sonic zhang wrote:
> Send again.
>
> In NOMMU arch, anonymous PIPE can't be accessed in child process if it is
> started
> by vfork/execve. This patch use named PIPE instead. The API sync_pipe_create()
> and sync_pipe_close() are changed to accept PIPE name.
>
>
> Signed-off-by: Sonic Zhang <[email protected]>
Thanks.
Regards--
Subrata
> ---
> include/libtestsuite.h
> lib/libtestsuite.c
>
> Index: include/libtestsuite.h
> ===================================================================
> --- include/libtestsuite.h (revision 147)
> +++ include/libtestsuite.h (revision 150)
> @@ -7,7 +7,14 @@
> *
> * notify_startup: notify the father process a son has started its execution.
> */
> -int sync_pipe_create( int fd[]);
> +#include <sys/types.h>
> +#include <fcntl.h>
> +#include <sys/stat.h>
> +
> +/* fifo_name is used to create named pipe. NULL means anonymous pipe. */
> +#define PIPE_NAME NULL
> +int sync_pipe_create( int fd[], const char *pipe_name);
> +int sync_pipe_close(int fd[], const char *pipe_name);
> int sync_pipe_wait( int fd[]);
> int sync_pipe_notify( int fd[]);
> -int sync_pipe_close(int fd[]);
> +
> Index: lib/libtestsuite.c
> ===================================================================
> --- lib/libtestsuite.c (revision 147)
> +++ lib/libtestsuite.c (revision 150)
> @@ -38,8 +38,8 @@
> #include <stdlib.h>
> #include <pwd.h>
> #include <errno.h>
> -#include <fcntl.h>
>
> +#include "libtestsuite.h"
> #include "test.h"
> #include "usctest.h"
>
> @@ -76,19 +76,56 @@
> }
> }
>
> -int sync_pipe_create(int fd[])
> +static char pipe_name[256];
> +
> +void generate_pipe_name(char *name)
> {
> - return pipe (fd);
> + char *p;
> +
> + p = rindex(name, '/');
> + if (p == NULL)
> + p = name;
> + else
> + p++;
> + snprintf(pipe_name, 255, "%s/ltp_fifo_%s", P_tmpdir, p);
> }
>
> -int sync_pipe_close(int fd[])
> +int sync_pipe_create(int fd[], const char *name)
> {
> + int ret;
> +
> + if (name != NULL) {
> + generate_pipe_name(name);
> +
> + ret = open(pipe_name, O_RDWR);
> + if (ret != -1) {
> + fd[0] = ret;
> + fd[1] = open(pipe_name, O_RDWR);
> + } else {
> + ret = mkfifo(pipe_name, S_IRWXU);
> + if (!ret) {
> + fd[0] = open(pipe_name, O_RDWR);
> + fd[1] = open(pipe_name, O_RDWR);
> + }
> + }
> + return ret;
> + } else
> + return pipe(fd);
> +}
> +
> +int sync_pipe_close(int fd[], const char *name)
> +{
> int r = 0;
>
> if (fd[0] != -1)
> r = close (fd[0]);
> if (fd[1] != -1)
> r |= close (fd[1]);
> +
> + if (name != NULL) {
> + generate_pipe_name(name);
> + unlink(pipe_name);
> + }
> return r;
> }
>
>
>
> ------------------------------------------------------------------------------
> This SF.net email is sponsored by:
> SourcForge Community
> SourceForge wants to tell your story.
> http://p.sf.net/sfu/sf-spreadtheword
> _______________________________________________
> Ltp-list mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/ltp-list
------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list