โŒ

Normal view

There are new articles available, click to refresh the page.
Before yesterdayMain stream

My function have to stop a thread only if n threads are running including itself [closed]

Thread T12 is only allowed to terminate while 6 threads (with also with himself) runs. "args" is the argument of the function that gives me the id of the running thread .

My code is running, but it exceeds its time limit.


    THREAD_struct * t1 = (THREAD_struct*) args ;

    if(t1->id != 12){
        pthread_mutex_lock(&lock) ;
        while(t12In == false ){ // global variable ->t12In was initialized with false
            pthread_cond_wait(&cond ,&lock);
        }
        pthread_mutex_unlock(&lock) ;
    }
    pthread_mutex_lock(&lock) ;

    runningTh++;
    if (runningTh == simThreads ){
        pthread_cond_broadcast(&cond) ; 
    }
    while(t1->id != 12 && runningTh <= simThreads){
        pthread_cond_wait(&cond ,&lock);
    }
    
    pthread_mutex_unlock(&lock) ;

    pthread_mutex_lock(&lock);
    if (t1->id == 12) {
        t12In = true ; 
        pthread_cond_broadcast(&cond) ; 
        while (runningTh < simThreads){
            pthread_cond_wait(&cond ,&lock);
        }
    }
    pthread_mutex_unlock(&lock);

 

    pthread_mutex_lock(&lock);
    if (t1->id == 12) {
        t12In = true ; runningTh++ ; 
        pthread_cond_broadcast(&cond) ; 
    }
    pthread_mutex_unlock(&lock);
 

Cloud Server from scratch

I'm trying to build a Cloud server in Ubuntu on my own but every tutorial said that a storage platform is required, like NextCloud, ownCloud, ... However, This link said that I can setup a simple network file share like NFS.
I'm just trying to test the following encryption modules: img and also my modified SSL protocol.
Is it actually possible to build a Private cloud server without using third-party storage platforms? If not, can I even test the modules using Nginx or Apache?

How to install mongodb inside lampp folder in linux ubuntu 22?

So I am trying to install mongodb inside lampp folder because my project is using path /opt/lampp/etc/php.ini for php.ini instead of /etc/php/8.2/cli/php.ini problem is that Class MongoDB\Driver\Manager not found error occurring so when I used php artisan serve the problem is solved I want to run my project without artisan and when i run without artisan it starts using cli /opt/lampp/etc/php.ini instead of /etc/php/8.2/cli/php.ini that is why this error is happening

So I am trying to install mongodb inside lampp folder because my project is using path /opt/lampp/etc/php.ini for php.ini instead of /etc/php/8.2/cli

I have tried sudo pecl install mongodb which installed mongodb inside /etc/php/8.2/cli instead of /opt/lampp/ folder also tried many adding php_mongodb.dll file inside /opt/lampp/include/php/ext but it is not working

also tried to run some commands but they did not work please help

AWS linux machine sshd service is not found

I have created an ubuntu instance of type t2 micro 25 gb ram in AWS console. I have edited the sshd.config file to set PasswordAuthentication yes and then restart the service I am getting the error message as below. I tried to updating the os and then installing openssh client. But this did not help me. I was able to do the same step last week with out issues. I am restarting the service for a devops POC but this one is blocking my work. Any help on this process would me appreciated

command :

sudo service sshd restart
Error:
Failed to restart sshd.service: Unit sshd.service not found.

Version:
#8-Ubuntu SMP Sat Apr 20 00:46:25 UTC 2024

##################Step 1############################### sshd.config file

set PasswordAuthentication yes

######################Step 2############################

sudo service sshd restart
Failed to restart sshd.service: Unit sshd.service not found.

#######################Step 3##################################

.ubuntu.com/ubuntu noble InRelease
Get:2 http://us-east-2.ec2.archive.ubuntu.com/ubuntu noble-updates InRelease [89.7 kB]
Hit:3 http://us-east-2.ec2.archive.ubuntu.com/ubuntu noble-backports InRelease
Hit:4 http://security.ubuntu.com/ubuntu noble-security InRelease
Fetched 89.7 kB in 1s (151 kB/s)
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
All packages are up to date.

#####################Step 5#######################################

 apt-get install openssh-server

########################Step 6####################################

systemctl -l --type service --all|grep ssh
32: command not found
root@ip-172-31-42-76:/etc/init.d# systemctl -l --type service --all|grep ssh
โ— ssh-keygen.service                             not-found inactive dead    ssh-keygen.service
  ssh.service                                    loaded    active   running OpenBSD Secure Shell server
โ— sshd-keygen.service                            not-found inactive dead    sshd-keygen.service
โ— sshd.service                                   not-found inactive dead    sshd.service

Use Timeshift to do a P2V migration to VMware

I'm going to ask this question and then come back to answer it. I have a system running Debian 12. It is configured with all the apps and settings. VMware has a utility called vCenter Standalone Converter. It is no longer "stand alone" because it requires that you have an ESXi server running, and that apparently cannot be run in a vm. A number of suggestions were found but did not really address the problem. It seemed that timeshift might provide a solution a my initial attempts did not result in a bootable vm. I would be interested if anyone has devised a way to do this and what their procedure is.

I thought that perhaps if I could get a complete copy of the source system that I might be able to boot a live iso in the VM rsync might help but it kept throwing errors that suggested that it was choking on circular symlinks.

I then did a dd of the source disk and tried to use qemu, vmware and vbox utilities to create a vmdk from the dd image. VMware didn't like any of those vmdk files.

Then I tried gzipping the source system and ran into similar issues. tar worked to create a copy of the system but by then I realized that it would be fraught with problems and didn't use the archive file.

Diffrences between cdev_add and device_create function?

I am newbie on linux device driver development. I can't understand what cdev_add actually do.I viewed some simple char device driver code and I saw, cdev_add and device_create function used together. For instance:

/* Create device class, visible in /sys/class */
dummy_class = class_create(THIS_MODULE, "dummy_char_class");
if (IS_ERR(dummy_class)) {
    pr_err("Error creating dummy char class.\n");
    unregister_chrdev_region(MKDEV(major, 0), 1);
    return PTR_ERR(dummy_class);
}

/* Initialize the char device and tie a file_operations to it */
cdev_init(&dummy_cdev, &dummy_fops);
dummy_cdev.owner = THIS_MODULE;
/* Now make the device live for the users to access */
cdev_add(&dummy_cdev, devt, 1);

dummy_device = device_create(dummy_class,
                            NULL,   /* no parent device */
                            devt,    /* associated dev_t */
                            NULL,   /* no additional data */
                            "dummy_char");  /* device name */

What cdev_add and device_create do in this code?

Non-column output of `ls` piped to `sed` [closed]

As far as I know, command sed precesses its input line by line. Thus, the following command successfully outputs only the directories in the current directory:

$ ls -p -1 | sed -n '/\/$/p'

Here option -1 to ls makes its output appear in a column, so sed can process it line by line. However, if I remove option -1 this command still works. Why? Without option -1 the output of ls is not a set of separated lines.

Why the gnome icon I set does not work for Jetbrains IDE

The system I am currently using is archlinux. The desktop environment is gnome.

I installed JetBrains Toolbox through AUR, and then used it to install many IDEs. However, the icons of these IDEs did not change to the icons I set through gnome-tweak. But the IDE I installed directly through AUR did change the icon. But IDEs installed via this method are not pretty, they have an extra bar at the top.

So I was wondering if there is any way to change the icons of those IDEs installed via JetBrains Toolbox.

Comparison of IDEs installed through different ways

The icon of the IDE on the left is installed by me using JetBrains Toolbox, and the one on the right is installed through AUR.


The IDE via JetBrains Toolbox

enter image description here

The IDE on this picture was installed via JetBrains Toolbox and it behaves well and has no extra bars on it. While this approach solved the current problem, it introduced new problems and this didn't really solve my problem.


The IDE via AUR

The IDE on this picture was installed via AUR, and it looks weird, with extra bars, and the font changed to the font I set in gnome-tweaks.

As far as I know, its icon can be modified by modifying the .desktop file. I found these .desktop files in ~/.local/share/applications. But their file names look weird, like this: jetbrains-clion-fada67bb-967d-41a6-902a-9555ae964c1d.desktop

When I opened the program for the first time after making the modification, it did become what I expected, but when I opened the toolbox , the file changed to its original appearance. It seems that the .desktop file is managed by the toolbox program.

I want to know if there is a way to change the native icon to the icon I have in gnome-tweak.

Java docker-compose permission denied in WSL DOCKER setup

I got a weird setup where I can't build the java image in wsl docker setup but I can do it in Windows Docker setup. The error is permission denied: unknown. I read that I need to add chmod +x file.sh inside dockerfile but still the same error. Problem is I can build the docker image in Windows Docker even without the chmod inside dockerfile

structure

.
โ”œโ”€โ”€ docker
โ”‚ย ย  โ”œโ”€โ”€ nginx
โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ conf.d
โ”‚ย ย  โ”œโ”€โ”€ Dockerfile
โ”‚ย ย  โ””โ”€โ”€ entrypoint.sh
โ”œโ”€โ”€ project
โ””โ”€โ”€ docker-compose.yml

docker-compose.yml

version: "3.8"
services:
  app:
    container_name: myapp-app
    # restart: always
    build: ./docker
    ports:
      - "8080:8080"
      - "5005:5005"
    tty: true
    volumes:
      - ./project:/var/www/project:cached
      - ./docker/entrypoint.sh:/usr/local/bin/entrypoint.sh:cached
      - ./.m2:/root/.m2

   ... other setup not related

Dockerfile

FROM eclipse-temurin:17-jdk-alpine

RUN apk add --no-cache bash procps curl tar

# common for all images
ENV MAVEN_HOME /usr/share/maven

COPY --from=maven:3.9.5-eclipse-temurin-11 ${MAVEN_HOME} ${MAVEN_HOME}
COPY --from=maven:3.9.5-eclipse-temurin-11 /usr/local/bin/mvn-entrypoint.sh /usr/local/bin/mvn-entrypoint.sh
COPY --from=maven:3.9.5-eclipse-temurin-11 /usr/share/maven/ref/settings-docker.xml /usr/share/maven/ref/settings-docker.xml

RUN ln -s ${MAVEN_HOME}/bin/mvn /usr/bin/mvn

ARG MAVEN_VERSION=3.9.5
ARG USER_HOME_DIR="/root"
# ENV MAVEN_CONFIG "$USER_HOME_DIR/.m2"

# WORKDIR
WORKDIR /var/www/project

#Start application
RUN ["chmod", "+x", "/usr/local/bin/entrypoint.sh"] # the chmod command recommended.
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]

CMD [""]

entrypoint.sh

#!/bin/sh
# You can set here anything you need before starting the spring boot application

clear
export JAVA_TOOL_OPTIONS=-Dspring-boot.run.jvmArguments=-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5005
while true; do
    sleep 1
done

Error stacktrace

ERROR: for myapp-app  Cannot start service app: failed to create task for container: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: exec: "/usr/local/bin/entrypoint.sh": permission denied: unknown

ERROR: for app  Cannot start service app: failed to create task for container: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: exec: "/usr/local/bin/entrypoint.sh": permission denied: unknown
ERROR: Encountered errors while bringing up the project.
make: *** [Makefile:4: up] Error 1

How to remove `{{i:` and `}}` in string sides

I want to replace all occurrences of

{{i:very long text with some [special](https://google.com) nested text *here*}}

to

very long text with some [special](https://google.com) nested text *here*

That is, in pseudocode, I want to get <text> from {{i:<text>}} in a text file.

I don't mind which tool you use: grep, awk, ... This could be a beginning.

VSCode in WSL: how to sudo a root file so I can edit it

WSL v.1 -- VSCode v1.40.1 (using 'Remote - WSL' extension 40.3)

How to open a root-owned file for edit using sudo and VSCode? (without running as root)

If I open a root file without sudo, I can't edit it (expected): $ code /etc/profile.d/custom-profile.sh $

enter image description here

But, if I try to sudo code the file, I get:

$ sudo code /etc/profile.d/custom-profile.sh
[sudo] password for xxxx:
sudo: code: command not found

Binarify's answer below shows that I can switch the default user to root, but I definitely don't want to be running as root, so I'm still looking for another solution.

โŒ
โŒ