vps_new上先跑起来新的gogs:

  482  docker pull gogs/gogs
  489  docker run -d --name=hbbys_gogs --memory=512M --cpus=2 --restart=always -p 10022:22 -p 10080:3000 -v /var/gogs:/data gogs/gogs

根据上诉代码,接着访问端口10080,接着对gogs进行配置,应看以下官方说明。注意,数据库就用sqlite,方便迁移。

接着将vps_old上的gogs文件,先压缩,接着通过scp命令传送到vps_new上。vps_new将老文件们取代/var/gogs,但/var/gogs/gogs/conf/app.ini仍用新的。

接着在app.ini中配置require_login_view=true, disalbe_registration=true

接着docker ps查看容器,接着docker restart 重启容器。

  1. 需要一些基础库文件
% ls env
asm_io.inc  asm_io.o  cdecl.h  driver.c

2. 汇编模板文件:

%include "asm_io.inc"


segment .data

segment .text
    global asm_main
asm_main:
    enter 0, 0
    pusha

    popa
    mov eax,0
    leave
    ret

3. 自己写的一键执行汇编文件的shell程序:

% cat /root/bin/exasm
if [ $# -eq 1 ]; then
    nasm -o "$1.m.o" -f elf "$1"
    gcc -m32 -o "$1.m" driver.c asm_io.o "$1.m.o"
    ./"$1.m"

    mv $1.m* ~/trash/
fi

if [ $# -eq 2 ]; then
    nasm -o "$1.m.o" -f elf "$1"
    gcc -g -m32 -o "$1.m" "$2" asm_io.o "$1.m.o"
    ./"$1.m"

    #mv "$1.m" ~/trash
    #mv "$1.m.o" ~/trash/
fi

4. 一般是这样运行汇编的:

% ls
asm_io.inc  asm_io.o  cdecl.h  driver.c  env  lab1.asm  m_temp.asm
% exasm lab1.asm

5. debug汇编程序

5.1 生成反汇编文件,

% cat /root/bin/asm_gen_out
if [ $# -eq 1 ]; then
    nasm -o "$1.m.o" -f elf "$1"
    gcc -g -m32 -o "$1.m" driver.c asm_io.o "$1.m.o"
    objdump -S "$1.m" > "$1.m.dis_asm"
fi
% asm_gen_out lab1.asm
% ls
asm_io.asm  asm_io.o  driver.c  lab1.asm.m          lab1.asm.m.o
asm_io.inc  cdecl.h   lab1.asm  lab1.asm.m.dis_asm  m_temp.asm

接着可以打开xxx.m.dis_asm看反汇编文件,可以看到指令的地址。可以通过vim搜索asm_main函数。

5.2 gdb调试汇编程序

% cat /root/bin/asm_debug
if [ $# -eq 1 ]; then
    nasm -o "$1.m.o" -f elf "$1"
    gcc -g -m32 -o "$1.m" driver.c asm_io.o "$1.m.o"
    gdb "$1.m"

fi
% asm_debug lab1.asm
GNU gdb (GDB) Red Hat Enterprise Linux 7.6.1-115.el7
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-redhat-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /root/pro/as/pcasl-linux/wut_asm/lab1.asm.m...done.
(gdb) 

可以通过如 b *0x80bbef在某个地址断点。可以通过si单步调试。

(gdb) b *0x80487d5
Breakpoint 1 at 0x80487d5
(gdb) c
The program is not being run.
(gdb) r
Starting program: /root/pro/as/pcasl-linux/wut_asm/lab1.asm.m 

Breakpoint 1, 0x080487d5 in asm_main ()
Missing separate debuginfos, use: debuginfo-install glibc-2.17-292.el7.i686
(gdb) si
0x080487da in asm_main ()

  1. 可用用unique_ptr而不是qt的QScopedPointer,后者一般是因为历史遗留而使用
  2. widget.setLayout和layout.addWidget会让 参数中的 变成当前这个的child.
  3. 具有parent、child关系的组件中,父组件会自动销毁子组件。

#include <fcntl.h>
#include <stdio.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>

int c = 1;
int main() {
  int ret;
  char *myfifo = "/tmp/myfifosharefile";
  ret=mkfifo(myfifo, 0666);
  pid_t pid = fork();
  int fd;
  if (pid == 0) {
    char buf[4096];
    fd = open(myfifo, O_RDONLY);
    read(fd, buf, 4096);
    printf("received:%s\n", buf);
    close(fd);

  } else {
    fd = open(myfifo, O_WRONLY); 
    char *msg = "hi";
    write(fd, msg, sizeof(msg));
    printf("%d\n", c++);
    close(fd);
    unlink(myfifo);
    wait(NULL);
  }
}

这个使用过程中涉及 阻塞

进程间通信之fifo,在阻塞模式下,只有当读和写模式都打开时才返回,否则一直阻塞;

非阻塞模式下,当读端没打开,则打开写端无效,返回错误。

建议你读一读UNP卷2。

a. 不使用O_NONBLOCK标志时,只读open要阻塞到某个其它进程为写而打开它为止

b. 不使用O_NONBLOCK标志时,只写open要阻塞到某个其它进程为读而打开它为止
c. 如果在open的时候指定O_NONBLOCK标志,当只读open时,没有进程为写而打开FIFO的话,会返回-1,只写open时,没有进程为读而打开FIFO的话也会返回-1表示失败。

以上的情况使FIFO的使用带来了一些不便,但有一个常用的技巧是,只要用O_RDWR(读写)来打开一个管道,则不会返回失败,而open也不会阻塞。两个进程使用FIFO来进行通信时,通常会使用两个FIFO,一个用于发送数据(即进行写操作),一个用于接收数据(即进行读操作),而这两个FIFO需要均使用O_RDWR来打开。使用系统调用open, read, write来操作这两个FIFO没有什么问题,程序工作得很好。
————————————————
版权声明:本文为CSDN博主「Mr_John_Liang」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/liangzhao_jay/article/details/47108977

这个-lrt必须放在最右边

-lrt表示使用library: librt

在CMakeLists.txt中指定lrt:

target_link_libraries(helloapp rt)

NAME
     librt, libposix4 - POSIX.1b Realtime Extensions library

SYNOPSIS
     cc [ flag... ] file... -lrt [ library... ]

DESCRIPTION
     Functions in this library provide  most  of  the  interfaces
     specified  by  the  POSIX.1b  Realtime Extension.  See stan-
     dards(5). Specifically, this includes the interfaces defined
     under   the   Asynchronous  I/O,  Message  Passing,  Process
     Scheduling, Realtime Signals Extension,  Semaphores,  Shared
     Memory  Objects,  Synchronized  I/O, and Timers options. The
     interfaces defined under the Memory  Mapped  Files,  Process
     Memory  Locking,  and  Range Memory Locking options are pro-
     vided in libc(3LIB)

     See the man pages for the individual interfaces  in  section
     3RT for information on required headers.

     The name libposix4 is maintained for backward  compatibility
     and  should be avoided. librt is the preferred name for this
     library.

当在linux下使用一些库,如<sys/shm.h>时,需要指定这个选项