Ubuntu

How to make parent process wait for child processes to finish?

社会主义新天地 提交于 2021-02-10 18:20:37
问题 I have an assignment which gives me this code to transform into a code that makes the parent process wait for all children processes to finish. PS: the first code has 4 processes and needs to use waitpid to solve this. #include <stdio.h> #include <stdlib.h> #include <sys/types.h> #include <unistd.h> int main(){ pid_t p = fork(); pid_t k = fork(); if(p>0){ printf("p=%d: PID = %d\n", p, getpid()); sleep(45); exit(0); } else if(p==0){ printf("p=%d: PID = %d\n", p, getpid()); exit(0); } else if(p

How to make parent process wait for child processes to finish?

左心房为你撑大大i 提交于 2021-02-10 18:19:43
问题 I have an assignment which gives me this code to transform into a code that makes the parent process wait for all children processes to finish. PS: the first code has 4 processes and needs to use waitpid to solve this. #include <stdio.h> #include <stdlib.h> #include <sys/types.h> #include <unistd.h> int main(){ pid_t p = fork(); pid_t k = fork(); if(p>0){ printf("p=%d: PID = %d\n", p, getpid()); sleep(45); exit(0); } else if(p==0){ printf("p=%d: PID = %d\n", p, getpid()); exit(0); } else if(p

Python Indicator stops updating after 3 times on Ubuntu

醉酒当歌 提交于 2021-02-10 18:13:59
问题 i am writing an Indicator in Python which should update every 5 minutes. Unfortunately the label is updated only 3 times, but then the label stays the same, although the thread still runs. For demonstration purpose, I replaced the data with the current time. #!/usr/bin/env python3 import signal import gi import threading gi.require_version('Gtk', '3.0') gi.require_version('AppIndicator3', '0.1') from gi.repository import Gtk, AppIndicator3, GObject import time class Indicator(): def __init__

20165208 预备作业3 Linux安装及学习

对着背影说爱祢 提交于 2021-02-10 17:01:09
20165208 预备作业3Linux安装及学习 Linux操作系统安装 此次安装我在进行Ubuntu安装时出现了问题,按照操作当我选择启动时弹出了“不能为虚拟机打开新任务”的提示框。通过上网查找资料,找到了问题所在,并最终解决了问题。具体操作为重启计算机,在出现开启页面时,快速连续多次按F1键弹出BIOS界面,将virtualiation中的disabled转换为enable即可。后续操作按照进程来尚未出现问题。 问题及解决方法如图 Linux命令的学习方法 Linux作为一个操作系统包括如下结构:shell、库函数、硬件、内核、系统调用、应用。与Windows操作系统没有什么大区别。具体操作主要通过命令进行使用。 命令: 格式:command [options] [arguments] 选项option是调整命令执行行为的开关,决定了命令的显示结果。参数argument是指命令的作用对象。注:ls和ls .等价。 man命令:printf查找帮助文档,-k搜索学习命令,-f查看命令的基本功能。 cheat命令:提供显示Linux命令使用案例,cheat 命令即可学习例子举一反三。 find命令:查找文件在系统中的位置 grep命令:对文件进行全文检索,格式为grep -n 所要查找的函数。 whereis,which命令:查找适用的命令工具安装位置。which相对更精确

Docker 基础 : 镜像

混江龙づ霸主 提交于 2021-02-10 16:57:15
作者: sparkdev 链接://www.cnblogs.com/sparkdev 镜像是 Docker 的三大核心概念之一。Docker 运行容器前需要本地存在对应的镜像,如果本地没有对应的镜像,Docker 会尝试从默认的镜像仓库下载。当然用户也可以通过配置,使用自定义的镜像仓库。 本文将介绍镜像的具体操作,包括使用 pull 命令从 Docker Hub 的镜像仓库中拉取(下载)公共镜像;查看本地已有的镜像信息;使用 search 命令搜索镜像;删除镜像标签和镜像文件;创建用户自定义镜像并上传到 Docker Hub 镜像仓库。 与镜像相关的操作都被定义在 docker image 子命令中,虽然不带 image 的格式依然被兼容,但带上 image 后会让命令更容易理解,也会有更好的自动补全效果。 获取镜像 本地镜像是运行容器的前提,所以在运行容器前我们需要使用 docker image pull 命令从网络上的镜像仓库把镜像拉取到本地。 该命令的格式为: docker image pull [OPTIONS] NAME[ :TAG| @DIGEST] 如果只指定了镜像的名称,默认会选择拉取 latest 标签标记的镜像。比如我们要拉取最新的 ubuntu 镜像: $ docker image pull ubuntu 该命令实际拉取的是 ubuntu:latest 镜像

Nginx: How to match ONLY the main domain with server_name

こ雲淡風輕ζ 提交于 2021-02-10 16:55:46
问题 My goal is to redirect example.com into www.example.com without redirecting any subdomain to www . This is what I have: server { listen 443; server_name example.com; return 301 https://www.$server_name$request_uri; } With this configuration every subdomain (ex: foo.example.com ) gets redirected into www.example.com , not just the main one without subdomain ( example.com ), as I would like. I tried cleaning cache (and also doing it from other browsers) with same results. Edit: The proof that

Autossh script running as systemctl start SERVICE works but systemctl enable SERVICE failed

送分小仙女□ 提交于 2021-02-10 16:16:54
问题 We are trying to get autossh to connect to remote server at boot time in Ubuntu 16.04.2. So we use systemctl to do the job. The script is as following: [Unit] Description=Keeps a tunnel to 'remote server' open After=network.target [Service] ExecStart=/usr/bin/autossh -NR 83232:localhost:22 -i /home/user/.ssh/id_rsa REMOTE_USER@REMOTE_IP [Install] WantedBy=multi-user.target It would work fine if we start the service by using start systemctl start SERVICE But it would fail if we use enable

Ubuntu 16.04 can't enable .htaccess

我怕爱的太早我们不能终老 提交于 2021-02-10 16:12:51
问题 I'm developing a website local and just switched from Windows to Ubuntu 16.04 - Sadly my .htaccess doesn't seems to work since rewrite rules don't apply and sources can't be found. I activated: sudo a2enmod rewrite rewrite_rule (shared) is listed via: sudo apache2ctl -M My website files (including my .htaccess) are located under /var/www/html My .htaccess Options +FollowSymLinks -MultiViews RewriteEngine On RewriteBase / # Hide Index IndexIgnore * # Forbid accessing certain sites

Killing all processes and threads in python3.X

柔情痞子 提交于 2021-02-10 14:50:20
问题 I'm writing a UI wrapper for reading some info using esptool.py I have two active threads: UI and procesing - SerialReader. UI class has reference to the SerialReader and should stop SerialReader when it gets the exit command. The problem is that I call esptool command which gets stuck in trying to read data over serial connection. class SerialReaderProcess(threading.Thread): def __init__(self, window): super().__init__() self.window = window self.logger = window.logger self.window.set_thread

Qemu showing as black screen for ARM (VM)

旧巷老猫 提交于 2021-02-10 14:25:48
问题 So I'm using this site to setup Qemu on my Lubuntu VM. https://azeria-labs.com/emulate-raspberry-pi-with-qemu/ My errors happen when im trying to run the Qemu but the screen appears as black and it says "Guest has not initialized the display (yet)." Looking at the error it says: Error: invalid dtb and unrecognized/unsupported machine ID r1=0x00000183 r2=0x00000100 r2[]=05 00 00 00 01 00 41 54 01 00 00 00 00 10 00 00 Available machine support: ID (hex) NAME ffffffff Generic DT based system