Ask a question about daemon

Look:
int main()
if(fork())
exit(0);
setsid();
//the second fork
if(fork())
exit(0);
//=========
int fd=open("/dev/tty",O_RDWR);
ioctl(fd, TIOCSCTTY, 1);
while(1)
sleep(20);
write(fd,"hello",10);
//daemon code
I am heard if I don't write the second fork,the process can connect
a control terminal,but I find I write the second fork or don't write
the codes,the screen couldn't display the string "hello",Why?
How to correct my codes?

leetow2006, have you read the manual page daemon(7)?  There a number of steps are given that system daemons should perform.  It says in step 7 that the second fork serves "to ensure the daemon can never re-acquire a terminal again."  So this seems to be a precautionary step, just in case.  Detaching from the terminal is done before that with setsid(), so ditching a controlling terminal seems unrelated to stdin/out and more related to the process hierarchy.  I am no expert, but my guess is that the daemon might be killed when the terminal exits if it does not detach, and might even be brought back  into the foreground and killed with Ctrl-C for example.  You don't want that for a daemon.

Similar Messages

  • Hello , how r u,  can i ask 1 question about xcode, i have mac os x 10.7.5 , n xcode version 4.6.3 i want build apps for ios 7.1 n mac os 1.9 ,, , but my macbook is old late 2008 macbook 4,1,  so can i develop apps for ios7 n 1.9 using xcode 4.6.3, bcz my

    hello , how r u,
    can i ask 1 question about xcode, i have mac os x 10.7.5 , n xcode version 4.6.3 i want build apps for ios 7.1 n mac os 1.9 ,, , but my macbook is old late 2008 macbook 4,1,  so can i develop apps for ios7 n 1.9 using xcode 4.6.3, bcz my machine cant upadte on 1.8 n 10.9,, ihave 2gb ram . core 2 duo pr, plz rely asap,
    thnxs

    Please type complete sentences and words.  This isn't an instant message program.
    https://developer.apple.com/support/ios/ios-dev-center.html

  • Hello , I want to ask some question about ipads \  How powerful is the iPad?  How useful is it for reading books, newspaper or magazines or for surfing the web? Can you identify any shortcomings of the device?   please help me :(

    Hello ,
    I want to ask some question about ipads \
    How powerful is the iPad? 
    How useful is it for reading books, newspaper or magazines or for surfing the web?
    Can you identify any shortcomings of the device?  
    please help me

    it's less powerful than your average computer. THink of it like a netbook but with a better processor.
    It'll do fine for surfing (although if you browse a lot of flash based sites you will need to get a third party browser since safari doesn't accommodate it)
    You may do OK on reading books, papers or magazines, especially if they have apps, but the ipad's screen is backlit, so it doesn't work well outdoors and you may need to fiddle with the brightness so that you don't get eye strain (it's just like doing too much reading from a computer screen)
    I would say the biggest short comings are data transfer. Apple's preferred work flow is that everything is done via iTunes or the internet....well people dont' always have 100% reliable always on internet access so you can find yourself in a situation where you can't get things on/off the iPad.
    By and large, it's a good device for day to day stuff, but is not a computer replacement.

  • I want to ask the question about phasor measurement.

    I want to ask the question about phasor measurement.the first one is that how can I accomplish the sychronized sampling with GPS?The other question is that how can I adjust the sampling rate for DAQ when the system frequency alter continuously.(if I used the DFT,due to the altering of frequency,I can't get the completed waveform)"

    Synchronising DAQ with GPS depends on the DAQ sampling rate. If the rate is higher than 2 Hz you can sample the 1PPS pulse of your GPS receiver together with your data.
    You change the sampling rate with the AI Clock Config.vi. You cannot do this on the fly so you must stop DAQ with AI Control.vi reconfigure the sampling rate and then start it again.
    Waldemar
    Waldemar
    Using 7.1.1, 8.5.1, 8.6.1, 2009 on XP and RT
    Don't forget to give Kudos to good answers and/or questions

  • Where Would be the best category to ask a question about using dashboard?

    Where Would be the best category to ask a question about using dashboard?

    However, don't ask it in this topic. Create a new topic for the question with a title describing that you are looking for Dashboard help.

  • I wanted to ask a questions about financing

    I want ask a question about financing 2 macbookpros?

    You need to call Apple about that. These are just user forums. We're all users here, like you.

  • HT3702 Hi I would like to ask a question about my billing for some things

    I would like to ask a question about my billing

    This is not Apple. These are user forums. Questions about billing, credit cards, etc. should be addressed directly to Apple.
    Apple Store Customer Service at 1-800-676-2775 or visit online Help for more information.
    To contact product and tech support visit online support site.
    For Mac App Store: Mac App Store Customer Service.
    For iTunes: Apple Support for iTunes - Contact Us

  • Hi , i'm new here and i would like to ask a question about iPad 2 . Well , actually when i hold my finger on any icon , its not jiggling , i need to fix the icons . May i know what can i do in this case ? thank you in advance ,

    Hi , i'm new here and i would like to ask a question about iPad 2 . Well , actually when i hold my finger on any icon , its not jiggling , i need to fix the icons . May i know what can i do in this case ? thank you in advance ,

    Try a reset. Hold the Sleep and Home button down for about 10 seconds until you see the Apple logo. Ignore the red slider.

  • Okay i just recently asked a question.about my factory unlocked iphone 3gs asking how to activate it but..

    i probably shouldnt say this but,okay i just recently asked a question.about my factory unlocked iphone 3gs asking how to activate it. so i got too excited of aving it and couldnt wait for my tmobile sim card to come  one more day. so i "hactivated" it (i know this voids all warrenty) and i jailbroke it just so i could use it as an ipod.it worked and i was syched.
    BUTTT.... it asked me if i wanted to update the software to 5.1 and i was like " oh yes id love to" and it started downloading it and it was inrecovery mode the whole time .
    when the download finished. i hit restore so i can put the software on the phone but the itunes had an error and the phone went glitchy and it does a rebooting loop. it shows the apple symbol with the slash through it for about 5 seconds and shuts off for a little bit (about another 5 seconds) and it starts up  then loops the process. ive managed to turn the phone off but if i start  it up it loops...what should i do? any help :/
    Also it does not show up in my itunes because it is turning off to fast to detect.

    Discussion of hacked phones is prohibited on these forums.  Sorry, you'll need to go elsewhere to get support for a j'broke iPhone.

  • Ask a question about GUP

    recently i designed a voice over ip , about 40 GW, 2 GK,all are 26 routers, i want to implement GK redundancy, i can use alternate method to config GK, but i want to use Cluster using GUP protocol, but we haven't used GUP before. i asked many person, they don't use yet.
    i want to ask a question
    are there any successful H.323 network using GUP.
    and how about it, reliable or smooth,
    thanks!
    jack

    GUP provides the following benefits:
    1) Sharing the load across several GKs
    2) Any single GK in the cluster can resolve an address for another member in the cluster
    3) You can cluster up to 5 GKs in a cluster to address redundancy and scaling requirements
    GUP is not suitable in an environment where a large number of endpoints are registered.

  • I asked a question about Firefox, now where is it?

    I asked a question on this forum about Firefox. How do I know if anyone answered it? Also, how do I find it again?

    '''My Contributions''' at the top of the main forum pages should show you all your postings here, when you are logged into this forum.
    There has been no answer posted. <br />
    https://support.mozilla.com/en-US/questions/806634?s=&as=s

  • Ask a question about smartform

    Hi expert,
         I have a question about smartform . Now I am doing a task about Purchase Order,
    when I create a new Purchase Order in Transaction ME21N , before I saved , I click the button to preview how it looks .
    as everyone knows , during that time , there is no Purchase Order created . So in the header text - > Price types , I write something in
    the text . I know the data , I can get it from table STXH , then use the function 'READ_TEXT'  to check if there is data in it according to
    TDNAME (in this case the tdname is purchase order ), but I didn't save it , so there is no purchase order , how can I get the data .
    I only want to get the data in type 'EKKO' , not 'EKPO'.
    kind regards
    Nick

    Hi...
    use this code..
    data : variable type c.
    first concatenate ekko-name ekpo-ebelp into one variable.
    and take one text element and give the name is variable
    ok...
    follow this steps..
    i think this is help full for u...
    thxs & regards,
    rahul

  • Where do I ask a question about frequent blue screen crashes?

    My Windows 7 32bit PC frequently crashes (blue or black screen, approx 3 times per day).  Last time it happened I checked the Event Viewer and there were 10 error events, ID 7010, 3058, 3028, 3029, 9002, 7042, 7040, 9000 and 455.  I don't know
    what any of that means but could this be the cause of the crashes?  And can it be rectified?

    Hi,
    I suggest asking your question over here (Participate -> Ask a Question):
    Windows forums on Microsoft Answers
    Good luck, hope it works out for you.
    Don't retire TechNet! -
    (Don't give up yet - 13,225+ strong and growing)

  • HT201303 All I want to do is ask a question about the legitimacy of an email I received from apple. Is there an email address for apple?

    I received an email about my credit card information from apple. How do I find out if this is a legitimate email from apple? I can't find an email address for apple so I can ask a simple question....so frustrating...

    Identifying legitimate emails from the iTunes Store - http://support.apple.com/kb/HT2075

  • I am trying to ask a question about iPhones, but it will not let me post - I get a message similar to this - you are not allowed to change the content.  Any help on this matter?

    I am trying to ask the following question: Just updated my iPhone5 to V 7.1.2 and can no longer print to my MFC 7860W from this phone.  I researched this issue on this forum and found answers from last October/November.....  Wary of downloading anything that was posted that long ago.  Wondering if there is anyway around this issue, with more recent information?  I was able to use this printer in the past by using Brother's iPrint App. 
    Thanks!!
    But when I hit post, I get an error message at the top - "you are not allowed to change this content"  Can anyone help me?

    I am assuming you got that message when attempting to post an old thread. The old post is probably locked/archived.
    FYI, posting on old threads usually yields no responses at all.
    I have requested that this post be moved to the iPhone forum where you might get assistance.
    Barry

Maybe you are looking for

  • Discrete Job Component Pick Release (SRS)

    Hi All , For Push - Supply type , we can issue items to the job manually . Could any one brief purpose of Discrete Job Component Pick Release (SRS) in WIP Thanks Kiran

  • CSS virtual-router master/master problem

    Dear all experts, I have two CSSs 11150 and have configured them as following: CSS-1# circuit VLAN100   ip address 172.10.10.101 255.255.255.0     ip virtual-router 1 priority 105 preempt     ip redundant-vip 1 172.10.10.1     ip critical-service 1 u

  • Update Nokia C700 device software using Ovi Suite ...

    Hi, I succeeded to connect to my Nokia C700 Device in Nokia Ovi Suite mode via USB and now when I try to update device software the Ovi Suite notifies that there is some Network Connection Problem while no firewall and network on Windows XP machine w

  • No Phone connected DKu 5 and CA 42 with Nokia Suit...

    Hi I am trying to connect my mobile to my PC. I am running Windows 98 SE. My phone is a 6110i I also tried it on my daughter's 3220 I bought a DKU 5 connector of the internet and installed the drivers. Then unstalled Nokia suite 5.8. Both operations

  • How to Sync Modified iPhoto Photos to New iPad?

    Hi, the question is really in the title. I have just returned from holiday and have edited 300+ photos in iPhoto. These have been synced to my iPad which is only showing the originals, not the modified versions. After searching these forums I found a