Menu

Interesting TTYStream question

Help
Anonymous
2002-02-07
2002-02-11
  • Anonymous

    Anonymous - 2002-02-07

    When using the constructor from the TTYStream class to open a TTY serial port.....

    TTYStream (const char *filename)

    ..... it seems that if a non-existing filename/TTY port name is used, my program causes a segmentation fault when the object is created. Now what I'm wondering is if there's a way to prevent this from happening when an illegal filename is used. Is it possible to use exceptions in this case? (There is very little documentation on how to use exceptions). Is there something else about the class that I don't know about?

    This program I am running is a real-time embedded system, and so my program cannot crash, but must die gracefully when an illegal filename is used.

    I am using Common C++ 1.6.2, running under Solaris 2.8, with GCC compiler version 2.95.5.

    Any help would be greatly appreciated!

    Marc

     
    • Frediano Ziglio

      Frediano Ziglio - 2002-02-09

      ??? version 1.6.2 ??
      Can you post the code ??

       
    • Anonymous

      Anonymous - 2002-02-11

      Here's some code to describe what I mean:
      -------------------------------------------

      class Door : public TTYSession
      {
      ...
      public:

      Door(char *TTYname);
      ...
      }

      Door::Door(char *TTYname) : TTYSession(TTYname)

      Door tempDoor;
      tempDoor = new Door("/dev/sts/ttyn11");
      // crashes here, when creating Door object

      If the TTY filename used is not on the system --> segmentation fault.

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.