LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 08-06-2007, 05:00 AM   #1
jack_zhou
LQ Newbie
 
Registered: Aug 2007
Posts: 3

Rep: Reputation: 0
uclinux fork problem


hi all,
my uclinux kernel version is 2.4.22, and uclibc version is 0.9.26. Now I have cross compiled konq/e and qte. but i have found fork() does not work well on my system.
when it calls fork(), the child process halted. I changed it to vfork(), then parent process halted. here is the test program.
#include <stdio.h>
#include <unistd.h>
Code:
int main()
{
        if(vfork() == 0){
                printf("Child process\n");
                sleep(5);
        }
        else{
                printf("Parent process\n");
        }
        return 0;
}
result is:
Child process
(after 5s)
Parent process

then I change to fork():
Code:
int main()
{
        if(fork() == 0){
                printf("Child process\n");
                sleep(5);
        }
        else{
                printf("Parent process\n");
        }
        return 0;
}
the result is:
Parent process

It seems the child process never run. Why does this happen. The konq/e crashs here.
By the way, my arm toolchain is 2.95.3.
 
Old 08-06-2007, 10:05 AM   #2
mallux
Member
 
Registered: Jun 2007
Location: London, UK
Distribution: Ubuntu, RHEL, Fedora
Posts: 46
Blog Entries: 1

Rep: Reputation: 16
From the uClinux FAQ (section 2.5) (my emphasis)

Quote:
Q. Does uClinux support multitasking? What limitations are imposed by not
having a MMU?

A. uClinux absolutely DOES support multi-tasking, although there are a
few things that you must keep in mind when designing programs...

1. uClinux does not implement fork(); instead it implements vfork().
This does not mean no multitasking, it simply means that the
parent blocks until the child does exec() or exit(). You can still
get full multitasking.
 
Old 08-06-2007, 08:42 PM   #3
jack_zhou
LQ Newbie
 
Registered: Aug 2007
Posts: 3

Original Poster
Rep: Reputation: 0
but how to get the child and parent process running at the same time?because in konq/e, the child process doesn't call exec(), and after vfork() the parent hangs up. I want to port konq/e into uclinux. Any suggestion? Thank you in advance.
 
Old 08-07-2007, 04:11 AM   #4
mallux
Member
 
Registered: Jun 2007
Location: London, UK
Distribution: Ubuntu, RHEL, Fedora
Posts: 46
Blog Entries: 1

Rep: Reputation: 16
I'm afraid I'm not familiar enough with uClinux or your application to offer suggestions, except that this Linux Journal article says this:

Quote:
Making an application use vfork instead of fork usually falls into the absolutely simple or incredibly difficult category. Generally, if the application does not fork and then exec() almost immediately, it needs to be checked carefully before fork() can be replaced with vfork().
... which doesn't sound promising. Good luck!
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
problem in building uClinux kernel bm_soe Red Hat 0 05-29-2007 11:55 PM
Fork exec problem bhupeshchawda Programming 3 04-19-2007 04:58 AM
Fork() problem MrBrain Programming 3 10-10-2004 04:52 PM
fork() problem linuxanswer Programming 3 04-02-2004 05:20 PM
Fork problem Rajneesh Programming 3 12-22-2003 06:45 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:18 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration