delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2005/01/10/16:55:20

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Message-ID: <af67552e05011013546a132992@mail.gmail.com>
Date: Mon, 10 Jan 2005 22:54:51 +0100
From: Eric Hoffman <clallosy AT gmail DOT com>
Reply-To: Eric Hoffman <clallosy AT gmail DOT com>
To: cygwin AT cygwin DOT com, Corinna Vinschen <corinna-cygwin AT cygwin DOT com>
Subject: Re: execv and then socket: "operation not permitted"
In-Reply-To: <20050109121953.GA5017@cygbert.vinschen.de>
Mime-Version: 1.0
References: <af67552e05010812586e656b9e AT mail DOT gmail DOT com> <20050109121953 DOT GA5017 AT cygbert DOT vinschen DOT de>
X-IsSubscribed: yes

------=_Part_1595_17252633.1105394091053
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

On Sun, 9 Jan 2005 13:19:53 +0100, Corinna Vinschen
<corinna-cygwin AT cygwin DOT com> wrote:
> 
> Could you please prepare a short testcase, only containing the
> necessary lines to reproduce the problem?
> 
> Thanks,
> Corinna
> 

I have attached 2 files to reproduce the problem. It is linked to the
putenv() call and the env variable then being reset.

Regards,

Eric

------=_Part_1595_17252633.1105394091053
Content-Type: text/plain; name="PacketServer.c"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment; filename="PacketServer.c"

#include <stdio.h>
#include <unistd.h>
#include <errno.h>


int
main(argc, argv)
int	argc;
char	*argv[];

{
	int Pid;
	int ret;
	int Pfd[2];
	int Flags;
       	char *cmd[] =3D { "ReadHandler",(char *)0 };
	static char fooflags[64];
=09
	printf("Entering PacketServer\n");

	strcpy(fooflags,"fooflags=3D1");
	putenv(fooflags);
	*fooflags =3D '\0'; /* remove from environment after all */

	switch ( Pid =3D fork() ) {

		case -1:		 /* Fork failed */
	    		perror("StartReadHandler: fork() failed");
	    		return(-1);
	    		break;		 /* NOT REACHED */

		case 0:			 /* Child process (will become read-handler) */
       			ret =3D execv ("./ReadHandler", cmd);
	    		perror("StartReadHandler: execv() failed");
	    		exit(-1);

		default:		 /* Parent process */
			printf("Leaving PacketServer \n");
	    	return(0);

    	} /* End of switch */

}





------=_Part_1595_17252633.1105394091053
Content-Type: text/plain; name="ReadHandler.c"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment; filename="ReadHandler.c"

#include <sys/types.h>
#include <sys/socket.h>
#include <stdio.h>



void perror(const char *s);
#include <errno.h>


/***** definitions *****/

int
main(argc, argv)
int	argc;
char	*argv[];

{
	int	fd;

	fprintf(stderr,"ReadHandler starting.\n");
   	fd =3D 0;
    	if ( ( fd =3D socket(AF_INET, SOCK_DGRAM, 0) ) =3D=3D -1 ) {
=09=20=20=20=20=09
		perror("socket:");
		fprintf(stderr,"Can't create UDP receive socket: socket()");
		return(-1);
	}
=09
	fprintf(stderr,"Socket created OK. \n");
	return(0);
}






------=_Part_1595_17252633.1105394091053
Content-Type: text/plain; charset=us-ascii

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/
------=_Part_1595_17252633.1105394091053--

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019