Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , 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: Date: Mon, 10 Jan 2005 22:54:51 +0100 From: Eric Hoffman Reply-To: Eric Hoffman To: cygwin AT cygwin DOT com, Corinna Vinschen Subject: Re: execv and then socket: "operation not permitted" In-Reply-To: <20050109121953.GA5017@cygbert.vinschen.de> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_Part_1595_17252633.1105394091053" References: <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 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 #include #include 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 #include #include void perror(const char *s); #include /***** 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--