Docsity

Advanced Programming in the UNIX, Thesis of Applications of Computer Sciences

Partial preview of the text

Download Advanced Programming in the UNIX and more Thesis Applications of Computer Sciences in PDF only on Docsity!

CS631 - Advanced Programming in the UNIX Environment

CS631 - Advanced Programming in the UNIX

Environment

Department of Computer Science Stevens Institute of Technology

Jan Schaumann

[email protected]

http://www.cs.stevens.edu/~jschauma/631/

Lecture 01: Introduction, UNIX history, UNIX Programming Basics

August 28, 2017

CS631 - Advanced Programming in the UNIX Environment

New Rules

Close your laptops!

Lecture 01: Introduction, UNIX history, UNIX Programming Basics

August 28, 2017

CS631 - Advanced Programming in the UNIX Environment

It is The class is called “Advanced Programming in the UNIX Environment”. About this class

not

an introduction to C an introduction to programming an introduction to Unix

Lecture 01: Introduction, UNIX history, UNIX Programming Basics

August 28, 2017

CS631 - Advanced Programming in the UNIX Environment

What is it?

http://cm.bell-labs.com/who/dmr/chist.html

Lecture 01: Introduction, UNIX history, UNIX Programming Basics

August 28, 2017

CS631 - Advanced Programming in the UNIX Environment

Lecture 01: Introduction, UNIX history, UNIX Programming Basics$ int socketpair(int, int, int, int *);int socket(int, int, int);int setsockopt(int, int, int, const void *, socklen_t);ssize_t sendmsg(int, const struct msghdr *, int);ssize_t sendto(int, const void *,ssize_t send(int, const void *, size_t, int);ssize_t recvmsg(int, struct msghdr *, int);ssize_t recvfrom(int, void * __restrict, size_t, int,ssize_t recv(int, void *, size_t, int);int listen(int, int);int getsockopt(int, int, int, void * __restrict, socklen_t * __restrict);int connect(int, const struct sockaddr *, socklen_t);int bind(int, const struct sockaddr *, socklen_t);int accept(int, struct sockaddr * __restrict, socklen_t * __restrict); $ grep "(int" /usr/include/sys/socket.h In a nutshell: the ”what”

August 28, 2017

CS631 - Advanced Programming in the UNIX Environment

In a nutshell: the ”what”

understand fundamental OS concepts (with focus on UNIX family): gain (systems) programming experience gain an understanding of the UNIX operating systems

basic network programming using a client/server model interprocess communication process relationships basic and advanced I/O multi-user concepts

Lecture 01: Introduction, UNIX history, UNIX Programming Basics

August 28, 2017

CS631 - Advanced Programming in the UNIX Environment

In a nutshell: the ”how”

if (isatty(STDOUT_FILENO)) {/* Terminal defaults to -Cq, non-terminal defaults to -1. */setlocale(LC_ALL, "");setprogname(argv[0]);const char *p;int kflag = 0;int ch, fts_options;struct winsize win; static char dot[] = ".", *dotav[] = { dot, NULL };

if (ioctl(STDOUT_FILENO, TIOCGWINSZ, &win) == 0 &&

termwidth = win.ws_col;win.ws_col > 0)

f_column = f_nonprint = 1;

} else

f_singlecol = 1;

if (!getuid())/* Root is -A automatically. */

f_listdot = 1;

while ((ch = getopt(argc, argv, "1ABCFLRSTWabcdfghiklmnopqrstuwx")) != -1) {fts_options = FTS_PHYSICAL;

/switch (ch) { / shell aliasing works correctly. The -1, -C, -l, -m and -x options all override each other so

case '1':

f_singlecol = 1;

Lecture 01: Introduction, UNIX history, UNIX Programming Basics

August 28, 2017

CS631 - Advanced Programming in the UNIX Environment

Lecture 01: Introduction, UNIX history, UNIX Programming Basics$ Hooray!$ echo "Hooray!"$ ./cmd$ cc -Wall -g -o cmd cmd.c $ $EDITOR cmd.c In a nutshell: the ”how”

August 28, 2017

CS631 - Advanced Programming in the UNIX Environment

Lecture 01: Introduction, UNIX history, UNIX Programming Basics$ Hooray!$ echo "Hooray!"$ ./cmd$ cc -Wall -g -o cmd cmd.c $ $EDITOR cmd.c In a nutshell: the ”how”

August 28, 2017

CS631 - Advanced Programming in the UNIX Environment

Lecture 01: Introduction, UNIX history, UNIX Programming Basics$ cmd.c:19: error: parse error before "return"cmd.c: In function `main':$ cc -Wall -g -o cmd cmd.c $ $EDITOR cmd.c In a nutshell: the ”how”

August 28, 2017

CS631 - Advanced Programming in the UNIX Environment

#0Loaded symbols for /usr/libexec/ld.elf_soProgram terminated with signal 11, Segmentation fault.$ gdb ./cmd cmd.core!@#!@!!!??#@!$ echo "!@#!@!!!??#@!"Memory fault (core dumped)$ ./cmd$ cc -Wall -g -o cmd cmd.c$ $EDITOR cmd.ccmd.c:19: error: parse error before "return"cmd.c: In function `main':$ cc -Wall -g -o cmd cmd.c $ $EDITOR cmd.c In a nutshell: the ”how”

0xbbbc676a in __findenv () from /usr/lib/libc.so.

Lecture 01: Introduction, UNIX history, UNIX Programming Basics(gdb)

August 28, 2017

CS631 - Advanced Programming in the UNIX Environment

Programming

https://i.imgur.com/WnpMFjX.jpg https://i.imgur.com/ZyeCO.jpg

Lecture 01: Introduction, UNIX history, UNIX Programming Basics

August 28, 2017

CS631 - Advanced Programming in the UNIX Environment

Syllabus

Review Code reading, coding style, best practices Encryption Advanced I/O: Nonblocking I/O, Polling, and Record Locking Daemon Processes, shared libraries Interprocess Communication Process Groups, Sessions, Signals Process Environment, Process Control UNIX tools: make(1), gdb(1), revision control, etc. Filesystems, System Data Files, Time & Date Files and Directories File I/O, File Sharing Introduction, UNIX history, UNIX Programming Basics

Lecture 01: Introduction, UNIX history, UNIX Programming Basics

August 28, 2017

CS631 - Advanced Programming in the UNIX Environment

UNIX History

Lecture 01: Introduction, UNIX history, UNIX Programming Basics

August 28, 2017