Find the answer to your Linux question:
Results 1 to 4 of 4
I made a while loop which exits if the user types 'exit' But when my shell exit the whole linux become stuck.and there no way lefts behind instead of stoping ...
  1. #1
    Just Joined!
    Join Date
    Mar 2009
    Posts
    8

    Red face problem in while loop of shell and problem in gets(char *s)

    I made a while loop which exits if the user types 'exit'
    But when my shell exit the whole linux become stuck.and there no way lefts behind instead of stoping and rebooting the linux on VMware.

    kindly help me if there is another way of closing the loop and returning to the original positio;

    e.g
    [MyshellOS]$ exit

    it must show that
    [root@localDesktop]# what is the proper way??


    second problem:
    I had used it to get the input from the user to enter commands...
    Is there any other way of getting a line from user instead of gets() and readline();

    "warning: the 'gets' function is dangerous and should not e used ."

  2. #2
    Just Joined!
    Join Date
    Feb 2009
    Posts
    45
    Quote Originally Posted by Rida
    I made a while loop which exits if the user types 'exit'
    But when my shell exit the whole linux become stuck.and there no way lefts behind instead of stoping and rebooting the linux on VMware.
    Did you write your own implementation of a shell? Iʼm afraid the description of your problemʼs context is too tenuous to expect any assisting answers.


    Quote Originally Posted by Rida
    I had used it to get the input from the user to enter commands...
    Is there any other way of getting a line from user instead of gets() and readline();

    "warning: the 'gets' function is dangerous and should not e used ."
    Yes, there is:
    Code:
    $> man 3 gets
    […]
    BUGS
           Never use gets().  Because it is impossible to tell without knowing the data in advance how many characters gets() will read, and because gets() will continue to store char‐
           acters past the end of the buffer, it is extremely dangerous to use.  It has been used to break computer security.  Use fgets() instead.
    
    […]

  3. #3
    Just Joined!
    Join Date
    Mar 2009
    Posts
    8

    Shell loop problem

    Yes I wrote my own shell!!
    please if there is any solution do help me!!

  4. #4
    Just Joined!
    Join Date
    Feb 2009
    Posts
    45
    Quote Originally Posted by Rida
    Yes I wrote my own shell!!
    Quote Originally Posted by Rida
    I made a while loop which exits if the user types 'exit'
    But when my shell exit the whole linux become stuck.
    I have further questions. I cannot help you unless you answer these questions:
    • What instructions follow after the user typed “exit”? Could it be that you forgot to handle certain signals or your signal handlers execute an infinite loop?
    • Which terminal(-emulator) do you use your shell with?
    • Do you implement job control?
    • Can you reduce the code in question to a minimum where the error still occurs? This way you could post the code here.
    • As for:
      Quote Originally Posted by Rida
      kindly help me if there is another way of closing the loop and returning to the original positio;

      e.g
      [MyshellOS]$ exit

      it must show that
      [root@localDesktop]# what is the proper way??
      Can you elaborate? I donʼt understand what you tried to convey with this sequence of letters.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...