Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Hi,,,
I am trying to learn writing code in user-space similar to the one below, using POSIX, but in addition to it to use an interrupt. this code will print "Hello World" each certain time. (I found this code in forum).
How can i learn programming using POSIX?
Are there any books recommended? or tutorials?
thanks
You should get yourself a copy of Advanced Programming in the UNIX Environment, 2nd Edition, by W. Richard Stevens and Stephen Rago. It is a giant book, but a great reference for POSIX programming and it highlights some of the differences you might run into between different implementations.
HI,
thanks it seems to be excellent reference.
could u plz clarify to me the difference (if there is) between POSIX we use in Liunx like timer_create(), clock_get_time(), etc...
and POSIX thread (by using <pthread.h> in Unix systems) ?
thanks
That FAQ page also has information on how to get a (free) copy of the standards document. I can't say I'd recommend reading it because it will probably only confuse you more.
Don't worry too much about POSIX compliance; there are parts that are not well-specified and often the poor specification is deliberate. However, because of the abundance of poorly defined specifications, writing a 100% POSIX compliant program doesn't mean you have a 100% portable program. As you read manual pages for various libc calls, you'll see comments like "BSD behaves THIS way, Solaris behaves THAT way, and GNU does things this other way". The most annoying differences occur where the specification doesn't explicitly state what arguments may be altered by the procedure, leading to cases where your code works fine on one operating system or with one set of C libraries, and corrupts data on other systems or when other C libraries are used.
Don't worry too much about POSIX compliance; there are parts that are not well-specified and often the poor specification is deliberate.
hi,
actually if u look to the code above. i have started analyzing it, (I am now learning how to use POSIX functions), the function "timer_connect()" is not found in any Linux manual pages, on the contrary i found it in VxWorks manual pages. Do u think it is going to work in Linux?
One more thing please:
the code above needs to add to it the <time.h>, <signal.h> and <stdio.h> headers.
Q1. do i need to put the "int main(int argcc, char argv[])" function or just ""void main() ?
Q2. how do u compile such code in Linux? is it like other C code by typing :
the function "timer_connect()" is not found in any Linux manual pages, on the contrary i found it in VxWorks manual pages. Do u think it is going to work in Linux?
Q1. do i need to put the "int main(int argcc, char argv[])" function or just ""void main() ?
Q2. how do u compile such code in Linux? is it like other C code by typing :
$ gcc -o test test.c
If timer_connect is not in the GNU libc manual (assuming you're using GNU libc) then the call does not exist. You can always grep through the system and library headers: fgrep -r "timer_connect" /usr/include One thing about POSIX is that you're not required to implement all procedures, so different systems or C libraries conform to different extents. For example, Microsoft claims that WinDuhs and their C compiler are POSIX compliant but most people have learned to ignore MS's claims.
You can still declare main as "void main()"; declaring with 'argc' and 'argv' is only useful if you will be parsing the command line for arguments. Also, you got 'argv' wrong - that should be "char *argv[]" or else "char **argv".
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.