DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 3 of 3

Thread: CYGWIN

  1. #1
    Join Date
    Feb 2008
    Posts
    1
    i need to check something with you
    what would you say this program would output (from the head, without compiling :))

    Code:
    #include <sys/types.h>
    #include <stdio.h>
    
    int main(){
    	pid_t pid;
    	pid = fork();
    	if (pid == 0) {
    		printf("A");
    		fork();
    		printf("B");
    	}
    	else if (pid > 0){
    		wait(NULL);
    		printf("C");
    	}
    }
    continue reading if you got the answer



    i'd like to know what you'll say, because that was a question on my exam.
    i answered ABBC and correct answer was ABABC

    but then i tested in cygwin and got ABBC and sometimes ABCB, but in linux the result was indeed ABABC

    is this a bug in cygwin, or it is a legitimate behaviour? if it's not a bug, how can i prove that to my professor and get my points ? :)

  2. #2
    Join Date
    Dec 2007
    Posts
    401
    > but then i tested in cygwin and got ABBC and sometimes ABCB
    the cygwin fork is similar to what was present in early flavors of UNIX. this behaviour is somewhat different from what posix specifies and what current UNIX implementations follow. see post #2 for details.

    > but in linux the result was indeed ABABC
    well, as per posix it could be either ABABC or ABCAB. on freebsd (6.3 stable) it is sometimes ABABC and some other times ABCAB. perhaps on linux it might always be ABABC (because of its non-reentrant kernel).

  3. #3
    Join Date
    Apr 2007
    Location
    Sterling Heights, Michigan
    Posts
    8,649
    Split from this thread into its own thread
    I don't answer coding questions via PM or Email. Please post a thread in the appropriate forum section.
    Please use [Code]your code goes in here[/Code] tags when posting code.
    Before posting your question, did you look here?
    Got a question on Linux? Visit our Linux sister site.
    Modifications Required For VB6 Apps To Work On Vista

Similar Threads

  1. eclipse --- cygwin?
    By classic_phone in forum C++
    Replies: 5
    Last Post: 04-02-2008, 03:52 PM
  2. fork for windows ???
    By Amahdy in forum C++
    Replies: 7
    Last Post: 02-09-2008, 03:16 AM
  3. Console I\O to Textbox in VB.NET
    By Jugg in forum .NET
    Replies: 4
    Last Post: 02-13-2006, 03:45 PM
  4. Using shell command with Cygwin
    By kgkidd in forum VB Classic
    Replies: 1
    Last Post: 09-15-2005, 06:27 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links