20135210--Information Security System Design Foundation Tenth Week study summary

Source: Internet
Author: User
Tags posix

Who command

Who reads the desired information into the memory and then prints it to the screen using the standard output function, closing the file.

View pre-logon user-who am I;

Lists the logged-on user-who or-W.

Error Handling in UNIX systems

    • UNIX style: For example, the fork function and the coat function, the return value includes both the error code and useful results.

      if((pid = wait(NULL))<0){    fprintf(stderr,"wait error:%s\n",strerror(errno));//将errno设置为指向错误原因的代码    exit(0);}
    • POSIX style: For example pthread, the function returns only the call succeeds (0) or fails (not 0), and any useful information is returned in the arguments passed in by invoking the reference.
    • DNS style: gethostbyname and gethostbyaddr retrieve NDS (domain Name System) libraries; they return null at the wrong time and set the global variable H_errno.
    • Error handling wrapper function

      • UNIX style

        pid_t Wait(int *status){    pid_t pid;    if(pid = wait(status)<0)        unix_error("wait error");    return pid;}
      • POSIX style

        void Pthread_detach(pthread_t tid){    int rc;    if(rc=pthread_detach(tid) != 0)        posix_error(rc,"Pthread_detach error");}
      • DNS Style

        struct hostent *Gethostbyname(const char *name){    struct hostname *p;    if((p = gethostbyname(name)) == NULL)        dns_error("Gethostbyname error");    return p;}
Error handling wrapper function
    • UNIX style: Returns void when successful, returns an error when the wrapper function prints a message, and then exits.
    • POSIX style: Returns void on success and does not contain useful results in the error return code.
    • DNS style: Returns a null pointer on failure, and sets the global variable H_errno.

Share files
    • Descriptor tables: A separate table for each process
    • File tables: All processes shared, file locations, reference counts, and pointers to V-node tables
    • V-node table: All process sharing, storing file information

Standard I/O

The standard I/O library models an open file as a stream, and a stream is a pointer to the structure of the file type.

    • General: This library provides a higher-level alternative to UNIXI/O.
    • Type:
      • Functions for opening and closing files (fopen and fclose);
      • Functions for reading and writing sections (Fread and fwrite);
      • Functions for reading and writing strings (Fgets and Fputs)
    • Flow application: A stream is a pointer to a structure of type file (for example, every Asni C file opens, it will open stdin,stdout,stderr three streams at the same time).
      • Meaning: A stream is an abstraction of a file descriptor and a stream buffer. (The purpose of the stream buffer is similar to Rio, which is to reduce the number of expensive UNIX system calls)
ls command

Ls-l View detailed properties of all visible files in the current directory in a long form

The ls-a listed contains the following "." The file that starts with

Ls-lu Last access time

ls-s file size in blocks

Ls-t Sorting by Time

Ls-f Display file types

20135210--Information Security System Design Foundation Tenth Week study summary

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.