天道酬勤,学无止境

linux

gnome-terminal new tab with alias as command to execute

I've created an alias in .bashrc file as follows alias myproject = 'cd ~/Desktop/myproject' After saving the file when I restart my terminal, typing in myproject takes me to the project directory but when I try to use the alias as a command argument to a new gnome-terminal tab it throws an error, gnome-terminal --tab -e "myproject" throws the error There was an error creating the child process for this terminal Failed to execute child process "myproject" (No such file or directory) What is wrong with this ?

2021-06-15 18:05:14    分类:问答    linux   alias   gnome-terminal

c atoi() for wide chars on linux?

Is there a c atoi() equivalent for wide chars on Linux? I can find something for MS (wtoi) but I can find anything in a standard Linux lib.

2021-06-15 17:41:27    分类:问答    c   linux   atoi

Checking for memory leaks in a running program

I have a question out of curiosity relating to checking for memory leaks. Being someone who has used valgrind frequently to check for memory leaks in my code for the last year or two, I suddenly came to think that it only detects lost/unfreed memory after the life of the program. So, in light of that, I was thinking that if you have a long-running program which malloc()'s intermittently and doesn't free() until the application exits, then the potential to eat memory (not necessarily through leaks) is huge and isn't observable using these tools because they only check after the programs

2021-06-15 17:37:12    分类:问答    c   linux   debugging   memory-leaks

Is it efficient to use epoll with devices (/dev/event/…)?

I am working on a monothreaded process applet which creates a proxy virtual device (more precisely a virtual Xbox 360 pad); I do manage to create it with the uinput interface, I set it up properly and it works just fine. In order to feed commands to this virtual device, I read events from another real interface (in this case a PS3 pad), and I open the real device file with these flags: fd = open("/dev/input/event22", O_RDONLY); // open the PS3 pad The main loop is something like (minus error checking): while(run) { input_event ev = {0}; read(fd, &ev, sizeof(struct input_event)); // convert

2021-06-15 17:36:52    分类:问答    linux   event-handling   linux-device-driver   epoll   uinput

Timezone in date?

From where does the date command in Linux get the timezone information? I cannot see /etc/localtime file and /usr/share/zoneinfo directory in my system. Still when i execute the date command i get the following output Thu Dec 9 16:28:18 UTC 2010 Kindly tell me from where does the command get the timezone information? Thanks, LinuxPenseur

2021-06-15 17:18:03    分类:问答    linux   date   timezone   localtime

mv a file that contains spaces from a shell script

I am trying to mv a file (rename it to replace spaces with dashes). If I pass the source and dest arguments without quotes, the source is broken up because mv thinks it is the end of the argument. If I surround source and dest with arguments, mv reports that the source can't be found. Currently, $1 and $2 have hardcoded quotes at the beginning and end. $onam and $dnam are the equivalents without the hardcoded quotes. This command from a prompt works perfectly because source and dest are surrounded by quotes: mv "/home/bryan/renametest/TestFolder/test file" "/home/bryan/renametest/TestFolder

2021-06-15 17:15:14    分类:问答    linux   shell   mv

Linux: How to kill Sleep

More of a conceptual question. If I write a bash script that does something like control_c() { echo goodbye exit #$ } trap control_c SIGINT while true do sleep 10 #user wants to kill process here. done control+c won't exit when sleep 10 is running. Is it because linux sleep ignores SIGINT? Is there a way to circumvent this and have the user be able to cntrl+c out of a sleep?

2021-06-15 16:56:43    分类:问答    linux   bash   sleep

“Backtrace stopped: previous frame identical to this frame (corrupt stack?)” on ARM linux

I am trying to debug a segfault while running an application on linux ( ARM architecture). I copied the core dump file and tried to get the backtrace using arm-gdb on x86_64 host. This is the o/p: $ arm-arago-linux-gnueabi-gdb test_slave6_slave core GNU gdb (GDB) 7.4 Copyright (C) 2012 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 "-

2021-06-15 15:46:36    分类:问答    linux   gdb   arm   valgrind   stack-corruption

Howto use sed to remove only triple empty lines?

Howto use sed to remove only triple empty lines? For example: MyText.txt line1 line2 line3 line4 with the use of sed i want the result to look like this MyText.txt line1 line2 line3 line4 I was able to delete double empty lines with sed -i '/^$/{ N /^\n$/D }' MyText.txt However my goal is to delete triple empty lines and only triple empty lines. Any help would be much appreciated.

2021-06-15 15:37:35    分类:问答    linux   sed

Why does high-memory not exist for 64-bit cpu?

While I am trying to understand the high memory problem for 32-bit cpu and Linux, why is there no high-memory problem for 64-bit cpu? In particular, how is the division of virtual memory into kernel space and user space changed, so that the requirement of high memory doesn't exist for 64-bit cpu? Thanks.

2021-06-15 15:10:49    分类:问答    linux   cpu-architecture   virtual-memory