How do unix's handle multiple port opens?

How do unix's handle multiple port opens?

Post by Marty Leisner 257 » Fri, 03 Mar 1995 05:00:32



How asked on comp.unix.questions with no answers...

How do other unix's handle serial devices with multiple opens?

SunOS (and i think BSD) fails on the second open...

Linux repeatedly opens painlessly...

What is correct?

--
marty

Member of the League for Programming Freedom (see http://www.lpf.org/)

 
 
 

How do unix's handle multiple port opens?

Post by Steve Ra » Fri, 03 Mar 1995 23:48:28



>How asked on comp.unix.questions with no answers...

>How do other unix's handle serial devices with multiple opens?

>SunOS (and i think BSD) fails on the second open...

>Linux repeatedly opens painlessly...

>What is correct?

Here is the System V story:

It all depends on the driver.  Some drivers really want only one
application to use a device at a time, while most others don't
care.  Some drivers support overloading the O_EXCL (FEXCL) bit
to indicate that the application desires exclusive use of the
device.

For serial devices, drivers usually allow multiple opens of the
same port at the same time.  Otherwise implementing bidirectional
serial lines would be kind of difficult.  For example, with a
bidirectional line, uugetty will have tried to open the device,
and will be blocked in the driver's open routine until carrier
appears on the line.  If someone wants to call out on that line
(with cu, for example), they will open the device in nonblocking
mode and initiate the connection.  When carrier appears, uugetty
will see that there is a lock file for the device and close its
file descriptor for the device.

Steve Rago


 
 
 

1. in 'getopt()', how to handle multiple options in the 'optarg' string?

Hi All,

Pardon the possible idiocy of this question:

I'm trying to use the 'getopt' routine for handling command-line flags and
while most of it works like a charm, I need to have 1 flag that has 2
arguments:

progname -g 10 filename  yadda yadda yadda

optarg is declared as an 'extern char *', as per the man page for this,
and after the call to getopt, is supposed to point to the beginning of the
variable string.  I read this to mean that after the call, optarg should
point to the string "10 filename".

However, using an intermediate pointer 'tempstr' (because I can't examine
'optarg' directly for some reason (Is that a clue?)), I see with my
debugger that after:
   .
   .
while ((c = getopt(argc, argv, "Lsvqhf:n:o:m:M:b:e:R:g:l:t:T:C:F:w:")) != EOF)
   .
   .
tempstr = optarg;

<now look at tempstr in memory, from the above example>

1 0 \0 f i l e n a m e \0

it looks like it's there but as 2 null-terminated strings instead of one,
so I can't read it in with a 'sscanf()' or suchlike.

Two questions:
1) Is this the correct action of getopt? (almost certainly 'yes' - I'm a
novice at this)

2) What is the usual way of extracting multiple options per flag using getopt?

Thanks in advance for any enlightenment.
Cheers
harry
--
Harry J Mangalam, MolBio+Biochem / Dev+Cell Bio, Rm 4201, BioSciII  UC
Irvine, Irvine, CA, 92717, (714) 824-4824, fax (714) 824 8598
--
Harry J Mangalam, MolBio+Biochem / Dev+Cell Bio, Rm 4201, BioSciII  UC Irvine, Irvine, CA, 92717, (714) 824-4824, fax (714) 824 8598

2. Linux NIS HOWTO

3. multiple IP's ....TFTP deamon can't handle that!?

4. help: Install SW from NEC CDROM-260

5. PC / Terminal to handle multiple console ports

6. Very strange !!! Please Help Me; Reply-To: copernico@tin.it

7. Can Linux Handle Multiple CPU's

8. named causes demand pppd to dialup at boot

9. EXCHANGING OPTICAL DISKS : DOS to UNIX / UNIX to DOS

10. Solaris' latency in re-connecting to a port (was: Are multiple connect()'s valid?)

11. Does port 443 need to be open to 'POST' to an HTTPS site?

12. Unix equivalent to DOS 'IF EXIST'

13. DOS program for managing multiple Unix consoles